-
Notifications
You must be signed in to change notification settings - Fork 34
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
Fix/ tools #169
Fix/ tools #169
Conversation
@@ -119,7 +119,7 @@ | |||
* Never use Markdown syntax highlighting, such as ```json```. Only output the raw json string. | |||
* This is incorrect:"```json{{\n \"queries\": [\"term1\", \"term2\"]}}```" | |||
* This is incorrect:```json"{{\n \"queries\": [\"term1\", \"term2\"]}}"``` | |||
* This is correct:"{{\n \"quries\": [\"term1\", \"term2\"]}}" | |||
* This is correct:"{{\n \"queries\": [\"term1\", \"term2\"]}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, which mightve played a role in invalid responses from claude
"""Custom OpenAI embedding function""" | ||
|
||
def __init__(self, *args: Any, **kwargs: Any) -> None: | ||
"""Initialize custom OpenAI embedding function""" | ||
super().__init__(*args, **kwargs) | ||
# OpenAI@v1 compatible | ||
self._client = openai.embeddings | ||
|
||
def __call__(self, texts: Documents) -> Embeddings: | ||
"""Return embedding""" | ||
# replace newlines, which can negatively affect performance. | ||
texts = [t.replace("\n", " ") for t in texts] | ||
|
||
# Call the OpenAI Embedding API | ||
embeddings = self._client.create(input=texts, model=self._model_name).data | ||
|
||
# Sort resulting embeddings by index | ||
sorted_embeddings = sorted(embeddings, key=lambda e: e.index) # type: ignore | ||
|
||
# Return just the embeddings | ||
return [result.embedding for result in sorted_embeddings] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required as the default one is not compatible with openai@v1
# MODELS | ||
|
||
MAX_TEXT_LENGTH = 7500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@namesty we need to make sure the length of the text doesnt exceed the limitations of the model. Added this in here for now, please propose a more appropriate number / algorithm to avoid this if you think this is not ok.
This PR fixes misc issues with tools.