Skip to content

Getting a fix response data structure #367

Description

@didardivani

Describe the bug

I sent a prompt and ask to return the result with a fixed structure by adding "please return these ideas as a JSON Object with the structure { 'Idea':['Title':'string','Description':'string']} and using a maximum of 567 tokens per idea." to the end of prompt. but I have different result every time I try to get data.

To Reproduce

        var queryModel = new openAIModel
        {
            model = 'text-davinci-002',
            prompt = '',
            temperature = artificialIntelligencePreference.Temperature,
            max_tokens = maxCompletionLength
        };

string json = JsonConvert.SerializeObject(queryModel);

request.AddJsonBody(json);

var responseContent = templateApi.Execute(request); ---> response = openai.ChatCompletion.create(model=request_data["model"],
max_tokens=request_data["max_tokens"],
temperature=request_data["temperature"],
messages = request_data["message"])
return responseContent.Content;

Code snippets

this is the result which I get :

1- {"choices":[{"finish_reason":"stop","index":0,"logprobs":null,"text":"\n\n1. Join or attend an event for senior .NET developers\n2. Get a mentor to help guide your development journey\n3. Use online resources to improve your understanding of the platform\n4. Use social media to connect with other developers and learn from them\n5. Attend a .NET development conference\n6. Read books and blog posts about .NET development\n7. Watch online video tutorials about .NET development\n8. Take an online course about .NET development\n9. Use Visual Studio to its fullest potential\n10. Get involved in the open source .NET community"}],"created":1680191774,"id":"cmpl-6zovGa10EKPEVJBpnB1ZkiRmkHcmg","model":"text-davinci-002","object":"text_completion","usage":{"completion_tokens":119,"prompt_tokens":38,"total_tokens":157}}

2-{"choices":[{"finish_reason":"stop","index":0,"logprobs":null,"text":"\n\n1. ASP.NET Core MVC\n\nDescription: ASP.NET Core MVC is a framework for building web applications using the Model-View-Controller design pattern. It is a powerful tool for creating rich and dynamic web applications.\n\n2. C#\n\nDescription: C# is a powerful object-oriented programming language that enables developers to create robust and scalable applications.\n\n3. .NET Framework\n\nDescription: The .NET Framework is a comprehensive and integrated development platform that provides a wide range of services and libraries for building applications.\n\n4. SQL Server\n\nDescription: SQL Server is a relational database management system that enables developers to create and manage databases.\n\n5. Visual Studio\n\nDescription: Visual Studio is an integrated development environment that provides a complete set of tools for developing applications."}],"created":1680192829,"id":"cmpl-6zpCHmuiUqbaWy8L1mP2ptcz2kuFh","model":"text-davinci-002","object":"text_completion","usage":{"completion_tokens":170,"prompt_tokens":64,"total_tokens":234}}

OS

windows10

Python version

python-dotenv==0.21.1

Library version

openai-python v0.26.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions