Skip to content

Commit

Permalink
Merge pull request #20 from Shreypandey/main
Browse files Browse the repository at this point in the history
Embedding generation in LLMManager
  • Loading branch information
sameersegal authored Apr 17, 2024
2 parents 08ca820 + fb8d2f8 commit 1b32903
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions jb-manager-bot/jb_manager_bot/parsers/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from typing import List
from openai import OpenAI, AzureOpenAI


Expand Down Expand Up @@ -119,3 +120,35 @@ def fn(cls, name, description, params, required):
},
},
}

@classmethod
def generate_embeddings(
cls,
inputs: List[str],
model: str,
openai_api_key=None,
azure_openai_api_key=None,
azure_openai_api_version=None,
azure_endpoint=None,
**kwargs
):
"""Use the OpenAI Embeddings API to generate embeddings for the given inputs."""
client = cls.get_client(
openai_api_key=openai_api_key,
azure_openai_api_key=azure_openai_api_key,
azure_openai_api_version=azure_openai_api_version,
azure_endpoint=azure_endpoint,
)
args = {
k: v
for k, v in kwargs.items()
if k
in [
"encoding_format",
"dimensions",
]
}
response = client.embeddings.create(model=model, input=inputs, **args)
embeddings = [emb.embedding for emb in response.data]

return embeddings
2 changes: 1 addition & 1 deletion jb-manager-bot/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "jb-manager-bot"
version = "0.1.4"
version = "0.1.5"
description = "Bot for JugalBandi Manager"
authors = ["Shrey Pandey <[email protected]>", "Sameer Segal <[email protected]>", "Atharv Kirtikar <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 1b32903

Please sign in to comment.