Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add New Optional Parameters to AssistantRequest Struct #795

Merged
merged 2 commits into from
Jul 19, 2024

Conversation

Vanessamae23
Copy link
Contributor

Add New Optional Parameters to AssistantRequest Struct

This update introduces three new optional parameters to the AssistantRequest struct: ResponseFormat, Temperature, and TopP. These parameters provide additional control over the output format and sampling behavior of the OpenAI assistant, enhancing its flexibility and usability.

OpenAI Documentation Link

For detailed information about these parameters, please refer to the OpenAI API documentation: OpenAI API Reference

Solution Description

The solution involves extending the AssistantRequest struct to include the following fields:

  • ResponseFormat any: Specifies the format that the model must output. Example: setting this to { "type": "json_object" } ensures the model generates valid JSON. but it can also be a string format for 'auto'
  • Temperature *float32: Determines the sampling temperature.
  • TopP *float32: Defines the nucleus sampling parameter.

These additions enable users to specify advanced settings for response generation, aligning the API with the latest OpenAI features.

Struct Definition

Here is the updated AssistantRequest struct with the new fields included:

type AssistantRequest struct {
    Model         string                 `json:"model"`
    Name          *string                `json:"name,omitempty"`
    Description   *string                `json:"description,omitempty"`
    Instructions  *string                `json:"instructions,omitempty"`
    Tools         []AssistantTool        `json:"-"`
    FileIDs       []string               `json:"file_ids,omitempty"`
    Metadata      map[string]any         `json:"metadata,omitempty"`
    ToolResources *AssistantToolResource `json:"tool_resources,omitempty"`
    ResponseFormat any                   `json:"response_format,omitempty"`
    Temperature   *float32               `json:"temperature,omitempty"`
    TopP          *float32               `json:"top_p,omitempty"`
}

@Vanessamae23 Vanessamae23 force-pushed the add-more-parameters branch from f8f4d28 to 8a05028 Compare July 18, 2024 13:25
Copy link

codecov bot commented Jul 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.88%. Comparing base (774fc9d) to head (8a05028).
Report is 27 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #795      +/-   ##
==========================================
+ Coverage   98.46%   98.88%   +0.42%     
==========================================
  Files          24       26       +2     
  Lines        1364     1343      -21     
==========================================
- Hits         1343     1328      -15     
+ Misses         15        9       -6     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sashabaranov
Copy link
Owner

Duh, temperature and top_p are getting different types across the codebase 🤯 #9

image

Copy link
Owner

@sashabaranov sashabaranov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

@sashabaranov sashabaranov merged commit 966ee68 into sashabaranov:master Jul 19, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants