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

Support Tool Resources properties for Threads #760

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

pkosiec
Copy link
Contributor

@pkosiec pkosiec commented May 29, 2024

Describe the change

Support Tool Resources properties for Threads.

Provide OpenAI documentation link

Describe your solution
Describe how your changes address the problem or how they add the feature. This should include a brief description of your approach and any new libraries or dependencies you're using.

Tests
I've manually tested the functionality when using the library in the project I'm working on.

Additional context

Resolves #759

Copy link

codecov bot commented May 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.68%. Comparing base (774fc9d) to head (9b434df).
Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #760      +/-   ##
==========================================
+ Coverage   98.46%   98.68%   +0.22%     
==========================================
  Files          24       24              
  Lines        1364     1140     -224     
==========================================
- Hits         1343     1125     -218     
+ Misses         15        9       -6     
  Partials        6        6              

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

@temamagic
Copy link

@pkosiec Hello! Could you provide an example of how you use this? I tried to substitute a vector store in the request and am getting an error, would like to take a look at your version of using this

@pkosiec
Copy link
Contributor Author

pkosiec commented Jun 6, 2024

Hey @temamagic, this is how I used it:

	return  i.openaiClient.CreateThread(ctx, openai.ThreadRequest{
		Metadata: map[string]any{
			// ...
		},
		ToolResources: openai.ToolResourcesRequest{
			FileSearch: &openai.FileSearchToolResourcesRequest{
				VectorStoreIDs: []string{
					"{customVectorStoreID}",
				},
			},
		},
		Messages: []openai.ThreadMessage{
			{
				Role:    openai.ThreadMessageRoleUser,
				Content: "prompt",
			},
		},
	})

Hope that helps!

thread.go Outdated

type VectorStoreToolResources struct {
FileIDs []string `json:"file_ids,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Copy link
Owner

Choose a reason for hiding this comment

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

There's also a chunking_strategy field here

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! I've added a minor comment — we either can add an additional field or just merge as is!

@pkosiec
Copy link
Contributor Author

pkosiec commented Jun 13, 2024

Thank you @sashabaranov, let me add the field ASAP 👍

@pkosiec
Copy link
Contributor Author

pkosiec commented Jun 13, 2024

@sashabaranov Done: 9b434df

@sashabaranov sashabaranov merged commit 68acf22 into sashabaranov:master Jun 13, 2024
3 checks passed
@temamagic
Copy link

Hey @temamagic, this is how I used it:

	return  i.openaiClient.CreateThread(ctx, openai.ThreadRequest{
		Metadata: map[string]any{
			// ...
		},
		ToolResources: openai.ToolResourcesRequest{
			FileSearch: &openai.FileSearchToolResourcesRequest{
				VectorStoreIDs: []string{
					"{customVectorStoreID}",
				},
			},
		},
		Messages: []openai.ThreadMessage{
			{
				Role:    openai.ThreadMessageRoleUser,
				Content: "prompt",
			},
		},
	})

Hope that helps!

In my case, it helped to set the agents version to 2 after initializing the client, but thanks!

@pkosiec
Copy link
Contributor Author

pkosiec commented Jun 13, 2024

@temamagic Ah yes, forgot to mention that, sorry. Glad you figured it out!

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.

Missing Tool Resources for Threads
3 participants