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

Fix/ tools #169

Merged
merged 5 commits into from
Feb 20, 2024
Merged

Fix/ tools #169

merged 5 commits into from
Feb 20, 2024

Conversation

0xArdi
Copy link
Collaborator

@0xArdi 0xArdi commented Feb 19, 2024

This PR fixes misc issues with tools.

@@ -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\"]}}"
Copy link
Collaborator Author

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

Comment on lines +168 to +188
"""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]
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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.

@Adamantios Adamantios merged commit 7daacb3 into main Feb 20, 2024
6 checks passed
@Adamantios Adamantios deleted the fix/tools branch February 20, 2024 09:15
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.

3 participants