Kang Suhyun commited on
Commit
a4e8fcb
1 Parent(s): d72c56b

[#115|#116] Update model fetching and response format (#117)

Browse files

* [#115|#116] Update model fetching and response format

Changes:
- Secret manager will no longer be used to fetch the available model list.
- Models are instructed to return JSON responses to avoid unnecessary instructions like "Here is the summary...".
- Temporarily removed the Gemini model as we need to find a way to specify its specific model.
- Temporarily removed the EEVE model because it requires additional processing to get responses in JSON format.

* fix

* remove old models

Files changed (6) hide show
  1. README.md +0 -2
  2. model.py +93 -49
  3. poetry.lock +110 -5
  4. pyproject.toml +1 -1
  5. requirements.txt +2 -1
  6. response.py +1 -7
README.md CHANGED
@@ -46,9 +46,7 @@ Get Involved: [Discuss and contribute on GitHub](https://github.com/yanolja/aren
46
  Set your environment variables and run the app:
47
 
48
  ```shell
49
- GOOGLE_CLOUD_PROJECT=<your project id> \
50
  CREDENTIALS_PATH=<your crednetials path> \
51
- MODELS_SECRET=<your secret> \
52
  OPENAI_API_KEY=<your key> \
53
  ANTHROPIC_API_KEY=<your key> \
54
  MISTRAL_API_KEY=<your key> \
 
46
  Set your environment variables and run the app:
47
 
48
  ```shell
 
49
  CREDENTIALS_PATH=<your crednetials path> \
 
50
  OPENAI_API_KEY=<your key> \
51
  ANTHROPIC_API_KEY=<your key> \
52
  MISTRAL_API_KEY=<your key> \
model.py CHANGED
@@ -3,30 +3,12 @@ This module contains functions to interact with the models.
3
  """
4
 
5
  import json
6
- import os
7
  from typing import List
8
 
9
- from google.cloud import secretmanager
10
- from google.oauth2 import service_account
11
  import litellm
12
 
13
- from credentials import get_credentials_json
14
-
15
- GOOGLE_CLOUD_PROJECT = os.environ.get("GOOGLE_CLOUD_PROJECT")
16
- MODELS_SECRET = os.environ.get("MODELS_SECRET")
17
-
18
- secretmanager_client = secretmanager.SecretManagerServiceClient(
19
- credentials=service_account.Credentials.from_service_account_info(
20
- get_credentials_json()))
21
- models_secret = secretmanager_client.access_secret_version(
22
- name=secretmanager_client.secret_version_path(GOOGLE_CLOUD_PROJECT,
23
- MODELS_SECRET, "latest"))
24
- decoded_secret = models_secret.payload.data.decode("UTF-8")
25
-
26
- supported_models_json = json.loads(decoded_secret)
27
-
28
- DEFAULT_SUMMARIZE_INSTRUCTION = "Summarize the following text, maintaining the language of the text." # pylint: disable=line-too-long
29
- DEFAULT_TRANSLATE_INSTRUCTION = "Translate the following text from {source_lang} to {target_lang}." # pylint: disable=line-too-long
30
 
31
 
32
  class ContextWindowExceededError(Exception):
@@ -39,37 +21,106 @@ class Model:
39
  self,
40
  name: str,
41
  provider: str = None,
42
- # The JSON keys are in camelCase. To unpack these keys into
43
- # Model attributes, we need to use the same camelCase names.
44
- apiKey: str = None, # pylint: disable=invalid-name
45
- apiBase: str = None, # pylint: disable=invalid-name
46
- summarizeInstruction: str = None, # pylint: disable=invalid-name
47
- translateInstruction: str = None): # pylint: disable=invalid-name
48
  self.name = name
49
  self.provider = provider
50
- self.api_key = apiKey
51
- self.api_base = apiBase
52
- self.summarize_instruction = summarizeInstruction or DEFAULT_SUMMARIZE_INSTRUCTION # pylint: disable=line-too-long
53
- self.translate_instruction = translateInstruction or DEFAULT_TRANSLATE_INSTRUCTION # pylint: disable=line-too-long
54
-
55
- def completion(self, messages: List, max_tokens: float = None) -> str:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  try:
57
- response = litellm.completion(model=self.provider + "/" +
58
- self.name if self.provider else self.name,
59
- api_key=self.api_key,
60
- api_base=self.api_base,
61
- messages=messages,
62
- max_tokens=max_tokens)
 
 
 
 
 
 
63
 
64
- return response.choices[0].message.content
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  except litellm.ContextWindowExceededError as e:
67
  raise ContextWindowExceededError() from e
68
 
 
 
 
 
 
 
69
 
70
  supported_models: List[Model] = [
71
- Model(name=model_name, **model_config)
72
- for model_name, model_config in supported_models_json.items()
 
 
 
 
 
 
 
 
 
73
  ]
74
 
75
 
@@ -77,14 +128,7 @@ def check_models(models: List[Model]):
77
  for model in models:
78
  print(f"Checking model {model.name}...")
79
  try:
80
- model.completion(messages=[{
81
- "role": "system",
82
- "content": "You are a kind person."
83
- }, {
84
- "role": "user",
85
- "content": "Hello."
86
- }],
87
- max_tokens=5)
88
  print(f"Model {model.name} is available.")
89
 
90
  # This check is designed to verify the availability of the models
 
3
  """
4
 
5
  import json
 
6
  from typing import List
7
 
 
 
8
  import litellm
9
 
10
+ DEFAULT_SUMMARIZE_INSTRUCTION = "Summarize the given text without changing the language of it." # pylint: disable=line-too-long
11
+ DEFAULT_TRANSLATE_INSTRUCTION = "Translate the given text from {source_lang} to {target_lang}." # pylint: disable=line-too-long
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
 
14
  class ContextWindowExceededError(Exception):
 
21
  self,
22
  name: str,
23
  provider: str = None,
24
+ api_key: str = None,
25
+ api_base: str = None,
26
+ summarize_instruction: str = None,
27
+ translate_instruction: str = None,
28
+ ):
 
29
  self.name = name
30
  self.provider = provider
31
+ self.api_key = api_key
32
+ self.api_base = api_base
33
+ self.summarize_instruction = summarize_instruction or DEFAULT_SUMMARIZE_INSTRUCTION # pylint: disable=line-too-long
34
+ self.translate_instruction = translate_instruction or DEFAULT_TRANSLATE_INSTRUCTION # pylint: disable=line-too-long
35
+
36
+ def completion(self,
37
+ instruction: str,
38
+ prompt: str,
39
+ max_tokens: float = None) -> str:
40
+ messages = [{
41
+ "role":
42
+ "system",
43
+ "content":
44
+ instruction + """
45
+ Output following this JSON format:
46
+ {"result": "your result here"}"""
47
+ }, {
48
+ "role": "user",
49
+ "content": prompt
50
+ }]
51
  try:
52
+ response = litellm.completion(
53
+ model=self.provider + "/" + self.name if self.provider else self.name,
54
+ api_key=self.api_key,
55
+ api_base=self.api_base,
56
+ messages=messages,
57
+ max_tokens=max_tokens,
58
+ # Ref: https://litellm.vercel.app/docs/completion/input#optional-fields # pylint: disable=line-too-long
59
+ response_format={"type": "json_object"})
60
+
61
+ json_response = response.choices[0].message.content
62
+ parsed_json = json.loads(json_response)
63
+ return parsed_json["result"]
64
 
65
+ except litellm.ContextWindowExceededError as e:
66
+ raise ContextWindowExceededError() from e
67
+ except json.JSONDecodeError as e:
68
+ raise RuntimeError(f"Failed to get JSON response: {e}") from e
69
+
70
+
71
+ class AnthropicModel(Model):
72
+
73
+ def completion(self,
74
+ instruction: str,
75
+ prompt: str,
76
+ max_tokens: float = None) -> str:
77
+ # Ref: https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency#prefill-claudes-response # pylint: disable=line-too-long
78
+ prefix = "<result>"
79
+ suffix = "</result>"
80
+ messages = [{
81
+ "role":
82
+ "user",
83
+ "content":
84
+ f"""{instruction}
85
+ Output following this format:
86
+ {prefix}...{suffix}
87
+ Text:
88
+ {prompt}"""
89
+ }, {
90
+ "role": "assistant",
91
+ "content": prefix
92
+ }]
93
+ try:
94
+ response = litellm.completion(
95
+ model=self.provider + "/" + self.name if self.provider else self.name,
96
+ api_key=self.api_key,
97
+ api_base=self.api_base,
98
+ messages=messages,
99
+ max_tokens=max_tokens,
100
+ )
101
 
102
  except litellm.ContextWindowExceededError as e:
103
  raise ContextWindowExceededError() from e
104
 
105
+ result = response.choices[0].message.content
106
+ if not result.endswith(suffix):
107
+ raise RuntimeError(f"Failed to get the formatted response: {result}")
108
+
109
+ return result.removesuffix(suffix).strip()
110
+
111
 
112
  supported_models: List[Model] = [
113
+ Model("gpt-4o-2024-05-13"),
114
+ Model("gpt-4-turbo-2024-04-09"),
115
+ Model("gpt-4-0125-preview"),
116
+ Model("gpt-3.5-turbo-0125"),
117
+ AnthropicModel("claude-3-opus-20240229"),
118
+ AnthropicModel("claude-3-sonnet-20240229"),
119
+ AnthropicModel("claude-3-haiku-20240307"),
120
+ Model("mistral-small-2402", provider="mistral"),
121
+ Model("mistral-large-2402", provider="mistral"),
122
+ Model("llama3-8b-8192", provider="groq"),
123
+ Model("llama3-70b-8192", provider="groq"),
124
  ]
125
 
126
 
 
128
  for model in models:
129
  print(f"Checking model {model.name}...")
130
  try:
131
+ model.completion("You are an AI model.", "Hello, world!")
 
 
 
 
 
 
 
132
  print(f"Model {model.name} is available.")
133
 
134
  # This check is designed to verify the availability of the models
poetry.lock CHANGED
@@ -1508,6 +1508,109 @@ files = [
1508
  {file = "idna-3.7.tar.gz", hash = "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc"},
1509
  ]
1510
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1511
  [[package]]
1512
  name = "importlib-metadata"
1513
  version = "7.1.0"
@@ -1795,24 +1898,26 @@ test = ["pytest (==7.4.3)"]
1795
 
1796
  [[package]]
1797
  name = "litellm"
1798
- version = "1.39.5"
1799
  description = "Library to easily interface with LLM API providers"
1800
  optional = false
1801
  python-versions = "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,>=3.8"
1802
  files = [
1803
- {file = "litellm-1.39.5-py3-none-any.whl", hash = "sha256:1e8dd43c5d257fa8d7a0039b20aed7aeed4463d53608d1ba4ac233f1967a5330"},
1804
- {file = "litellm-1.39.5.tar.gz", hash = "sha256:8f4ea9fe21d67890e81a578e12c30b4172260ff35971dc7c3edf7eb69167d3be"},
1805
  ]
1806
 
1807
  [package.dependencies]
1808
  aiohttp = "*"
1809
  click = "*"
 
1810
  importlib-metadata = ">=6.8.0"
1811
  jinja2 = ">=3.1.2,<4.0.0"
1812
  openai = ">=1.27.0"
 
1813
  python-dotenv = ">=0.2.0"
1814
  requests = ">=2.31.0,<3.0.0"
1815
- tiktoken = ">=0.4.0"
1816
  tokenizers = "*"
1817
 
1818
  [package.extras]
@@ -3862,4 +3967,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more
3862
  [metadata]
3863
  lock-version = "2.0"
3864
  python-versions = "^3.11"
3865
- content-hash = "1a8c3540dde4c9707b6e8907efc355ff494385aa73275e9eb901270a658d9545"
 
1508
  {file = "idna-3.7.tar.gz", hash = "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc"},
1509
  ]
1510
 
1511
+ [[package]]
1512
+ name = "ijson"
1513
+ version = "3.3.0"
1514
+ description = "Iterative JSON parser with standard Python iterator interfaces"
1515
+ optional = false
1516
+ python-versions = "*"
1517
+ files = [
1518
+ {file = "ijson-3.3.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7f7a5250599c366369fbf3bc4e176f5daa28eb6bc7d6130d02462ed335361675"},
1519
+ {file = "ijson-3.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f87a7e52f79059f9c58f6886c262061065eb6f7554a587be7ed3aa63e6b71b34"},
1520
+ {file = "ijson-3.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:b73b493af9e947caed75d329676b1b801d673b17481962823a3e55fe529c8b8b"},
1521
+ {file = "ijson-3.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d5576415f3d76290b160aa093ff968f8bf6de7d681e16e463a0134106b506f49"},
1522
+ {file = "ijson-3.3.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4e9ffe358d5fdd6b878a8a364e96e15ca7ca57b92a48f588378cef315a8b019e"},
1523
+ {file = "ijson-3.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8643c255a25824ddd0895c59f2319c019e13e949dc37162f876c41a283361527"},
1524
+ {file = "ijson-3.3.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:df3ab5e078cab19f7eaeef1d5f063103e1ebf8c26d059767b26a6a0ad8b250a3"},
1525
+ {file = "ijson-3.3.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:3dc1fb02c6ed0bae1b4bf96971258bf88aea72051b6e4cebae97cff7090c0607"},
1526
+ {file = "ijson-3.3.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:e9afd97339fc5a20f0542c971f90f3ca97e73d3050cdc488d540b63fae45329a"},
1527
+ {file = "ijson-3.3.0-cp310-cp310-win32.whl", hash = "sha256:844c0d1c04c40fd1b60f148dc829d3f69b2de789d0ba239c35136efe9a386529"},
1528
+ {file = "ijson-3.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:d654d045adafdcc6c100e8e911508a2eedbd2a1b5f93f930ba13ea67d7704ee9"},
1529
+ {file = "ijson-3.3.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:501dce8eaa537e728aa35810656aa00460a2547dcb60937c8139f36ec344d7fc"},
1530
+ {file = "ijson-3.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:658ba9cad0374d37b38c9893f4864f284cdcc7d32041f9808fba8c7bcaadf134"},
1531
+ {file = "ijson-3.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2636cb8c0f1023ef16173f4b9a233bcdb1df11c400c603d5f299fac143ca8d70"},
1532
+ {file = "ijson-3.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cd174b90db68c3bcca273e9391934a25d76929d727dc75224bf244446b28b03b"},
1533
+ {file = "ijson-3.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:97a9aea46e2a8371c4cf5386d881de833ed782901ac9f67ebcb63bb3b7d115af"},
1534
+ {file = "ijson-3.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c594c0abe69d9d6099f4ece17763d53072f65ba60b372d8ba6de8695ce6ee39e"},
1535
+ {file = "ijson-3.3.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8e0ff16c224d9bfe4e9e6bd0395826096cda4a3ef51e6c301e1b61007ee2bd24"},
1536
+ {file = "ijson-3.3.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:0015354011303175eae7e2ef5136414e91de2298e5a2e9580ed100b728c07e51"},
1537
+ {file = "ijson-3.3.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:034642558afa57351a0ffe6de89e63907c4cf6849070cc10a3b2542dccda1afe"},
1538
+ {file = "ijson-3.3.0-cp311-cp311-win32.whl", hash = "sha256:192e4b65495978b0bce0c78e859d14772e841724d3269fc1667dc6d2f53cc0ea"},
1539
+ {file = "ijson-3.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:72e3488453754bdb45c878e31ce557ea87e1eb0f8b4fc610373da35e8074ce42"},
1540
+ {file = "ijson-3.3.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:988e959f2f3d59ebd9c2962ae71b97c0df58323910d0b368cc190ad07429d1bb"},
1541
+ {file = "ijson-3.3.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:b2f73f0d0fce5300f23a1383d19b44d103bb113b57a69c36fd95b7c03099b181"},
1542
+ {file = "ijson-3.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0ee57a28c6bf523d7cb0513096e4eb4dac16cd935695049de7608ec110c2b751"},
1543
+ {file = "ijson-3.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e0155a8f079c688c2ccaea05de1ad69877995c547ba3d3612c1c336edc12a3a5"},
1544
+ {file = "ijson-3.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7ab00721304af1ae1afa4313ecfa1bf16b07f55ef91e4a5b93aeaa3e2bd7917c"},
1545
+ {file = "ijson-3.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:40ee3821ee90be0f0e95dcf9862d786a7439bd1113e370736bfdf197e9765bfb"},
1546
+ {file = "ijson-3.3.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:da3b6987a0bc3e6d0f721b42c7a0198ef897ae50579547b0345f7f02486898f5"},
1547
+ {file = "ijson-3.3.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:63afea5f2d50d931feb20dcc50954e23cef4127606cc0ecf7a27128ed9f9a9e6"},
1548
+ {file = "ijson-3.3.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b5c3e285e0735fd8c5a26d177eca8b52512cdd8687ca86ec77a0c66e9c510182"},
1549
+ {file = "ijson-3.3.0-cp312-cp312-win32.whl", hash = "sha256:907f3a8674e489abdcb0206723e5560a5cb1fa42470dcc637942d7b10f28b695"},
1550
+ {file = "ijson-3.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:8f890d04ad33262d0c77ead53c85f13abfb82f2c8f078dfbf24b78f59534dfdd"},
1551
+ {file = "ijson-3.3.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b9d85a02e77ee8ea6d9e3fd5d515bcc3d798d9c1ea54817e5feb97a9bc5d52fe"},
1552
+ {file = "ijson-3.3.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e6576cdc36d5a09b0c1a3d81e13a45d41a6763188f9eaae2da2839e8a4240bce"},
1553
+ {file = "ijson-3.3.0-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e5589225c2da4bb732c9c370c5961c39a6db72cf69fb2a28868a5413ed7f39e6"},
1554
+ {file = "ijson-3.3.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ad04cf38164d983e85f9cba2804566c0160b47086dcca4cf059f7e26c5ace8ca"},
1555
+ {file = "ijson-3.3.0-cp36-cp36m-musllinux_1_2_aarch64.whl", hash = "sha256:a3b730ef664b2ef0e99dec01b6573b9b085c766400af363833e08ebc1e38eb2f"},
1556
+ {file = "ijson-3.3.0-cp36-cp36m-musllinux_1_2_i686.whl", hash = "sha256:4690e3af7b134298055993fcbea161598d23b6d3ede11b12dca6815d82d101d5"},
1557
+ {file = "ijson-3.3.0-cp36-cp36m-musllinux_1_2_x86_64.whl", hash = "sha256:aaa6bfc2180c31a45fac35d40e3312a3d09954638ce0b2e9424a88e24d262a13"},
1558
+ {file = "ijson-3.3.0-cp36-cp36m-win32.whl", hash = "sha256:44367090a5a876809eb24943f31e470ba372aaa0d7396b92b953dda953a95d14"},
1559
+ {file = "ijson-3.3.0-cp36-cp36m-win_amd64.whl", hash = "sha256:7e2b3e9ca957153557d06c50a26abaf0d0d6c0ddf462271854c968277a6b5372"},
1560
+ {file = "ijson-3.3.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:47c144117e5c0e2babb559bc8f3f76153863b8dd90b2d550c51dab5f4b84a87f"},
1561
+ {file = "ijson-3.3.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:29ce02af5fbf9ba6abb70765e66930aedf73311c7d840478f1ccecac53fefbf3"},
1562
+ {file = "ijson-3.3.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4ac6c3eeed25e3e2cb9b379b48196413e40ac4e2239d910bb33e4e7f6c137745"},
1563
+ {file = "ijson-3.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d92e339c69b585e7b1d857308ad3ca1636b899e4557897ccd91bb9e4a56c965b"},
1564
+ {file = "ijson-3.3.0-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:8c85447569041939111b8c7dbf6f8fa7a0eb5b2c4aebb3c3bec0fb50d7025121"},
1565
+ {file = "ijson-3.3.0-cp37-cp37m-musllinux_1_2_i686.whl", hash = "sha256:542c1e8fddf082159a5d759ee1412c73e944a9a2412077ed00b303ff796907dc"},
1566
+ {file = "ijson-3.3.0-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:30cfea40936afb33b57d24ceaf60d0a2e3d5c1f2335ba2623f21d560737cc730"},
1567
+ {file = "ijson-3.3.0-cp37-cp37m-win32.whl", hash = "sha256:6b661a959226ad0d255e49b77dba1d13782f028589a42dc3172398dd3814c797"},
1568
+ {file = "ijson-3.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:0b003501ee0301dbf07d1597482009295e16d647bb177ce52076c2d5e64113e0"},
1569
+ {file = "ijson-3.3.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:3e8d8de44effe2dbd0d8f3eb9840344b2d5b4cc284a14eb8678aec31d1b6bea8"},
1570
+ {file = "ijson-3.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9cd5c03c63ae06d4f876b9844c5898d0044c7940ff7460db9f4cd984ac7862b5"},
1571
+ {file = "ijson-3.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:04366e7e4a4078d410845e58a2987fd9c45e63df70773d7b6e87ceef771b51ee"},
1572
+ {file = "ijson-3.3.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:de7c1ddb80fa7a3ab045266dca169004b93f284756ad198306533b792774f10a"},
1573
+ {file = "ijson-3.3.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8851584fb931cffc0caa395f6980525fd5116eab8f73ece9d95e6f9c2c326c4c"},
1574
+ {file = "ijson-3.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bdcfc88347fd981e53c33d832ce4d3e981a0d696b712fbcb45dcc1a43fe65c65"},
1575
+ {file = "ijson-3.3.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:3917b2b3d0dbbe3296505da52b3cb0befbaf76119b2edaff30bd448af20b5400"},
1576
+ {file = "ijson-3.3.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:e10c14535abc7ddf3fd024aa36563cd8ab5d2bb6234a5d22c77c30e30fa4fb2b"},
1577
+ {file = "ijson-3.3.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:3aba5c4f97f4e2ce854b5591a8b0711ca3b0c64d1b253b04ea7b004b0a197ef6"},
1578
+ {file = "ijson-3.3.0-cp38-cp38-win32.whl", hash = "sha256:b325f42e26659df1a0de66fdb5cde8dd48613da9c99c07d04e9fb9e254b7ee1c"},
1579
+ {file = "ijson-3.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:ff835906f84451e143f31c4ce8ad73d83ef4476b944c2a2da91aec8b649570e1"},
1580
+ {file = "ijson-3.3.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:3c556f5553368dff690c11d0a1fb435d4ff1f84382d904ccc2dc53beb27ba62e"},
1581
+ {file = "ijson-3.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:e4396b55a364a03ff7e71a34828c3ed0c506814dd1f50e16ebed3fc447d5188e"},
1582
+ {file = "ijson-3.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e6850ae33529d1e43791b30575070670070d5fe007c37f5d06aebc1dd152ab3f"},
1583
+ {file = "ijson-3.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:36aa56d68ea8def26778eb21576ae13f27b4a47263a7a2581ab2ef58b8de4451"},
1584
+ {file = "ijson-3.3.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a7ec759c4a0fc820ad5dc6a58e9c391e7b16edcb618056baedbedbb9ea3b1524"},
1585
+ {file = "ijson-3.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b51bab2c4e545dde93cb6d6bb34bf63300b7cd06716f195dd92d9255df728331"},
1586
+ {file = "ijson-3.3.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:92355f95a0e4da96d4c404aa3cff2ff033f9180a9515f813255e1526551298c1"},
1587
+ {file = "ijson-3.3.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:8795e88adff5aa3c248c1edce932db003d37a623b5787669ccf205c422b91e4a"},
1588
+ {file = "ijson-3.3.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:8f83f553f4cde6d3d4eaf58ec11c939c94a0ec545c5b287461cafb184f4b3a14"},
1589
+ {file = "ijson-3.3.0-cp39-cp39-win32.whl", hash = "sha256:ead50635fb56577c07eff3e557dac39533e0fe603000684eea2af3ed1ad8f941"},
1590
+ {file = "ijson-3.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:c8a9befb0c0369f0cf5c1b94178d0d78f66d9cebb9265b36be6e4f66236076b8"},
1591
+ {file = "ijson-3.3.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:2af323a8aec8a50fa9effa6d640691a30a9f8c4925bd5364a1ca97f1ac6b9b5c"},
1592
+ {file = "ijson-3.3.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f64f01795119880023ba3ce43072283a393f0b90f52b66cc0ea1a89aa64a9ccb"},
1593
+ {file = "ijson-3.3.0-pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a716e05547a39b788deaf22725490855337fc36613288aa8ae1601dc8c525553"},
1594
+ {file = "ijson-3.3.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:473f5d921fadc135d1ad698e2697025045cd8ed7e5e842258295012d8a3bc702"},
1595
+ {file = "ijson-3.3.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:dd26b396bc3a1e85f4acebeadbf627fa6117b97f4c10b177d5779577c6607744"},
1596
+ {file = "ijson-3.3.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:25fd49031cdf5fd5f1fd21cb45259a64dad30b67e64f745cc8926af1c8c243d3"},
1597
+ {file = "ijson-3.3.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4b72178b1e565d06ab19319965022b36ef41bcea7ea153b32ec31194bec032a2"},
1598
+ {file = "ijson-3.3.0-pp37-pypy37_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7d0b6b637d05dbdb29d0bfac2ed8425bb369e7af5271b0cc7cf8b801cb7360c2"},
1599
+ {file = "ijson-3.3.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5378d0baa59ae422905c5f182ea0fd74fe7e52a23e3821067a7d58c8306b2191"},
1600
+ {file = "ijson-3.3.0-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:99f5c8ab048ee4233cc4f2b461b205cbe01194f6201018174ac269bf09995749"},
1601
+ {file = "ijson-3.3.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:45ff05de889f3dc3d37a59d02096948ce470699f2368b32113954818b21aa74a"},
1602
+ {file = "ijson-3.3.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1efb521090dd6cefa7aafd120581947b29af1713c902ff54336b7c7130f04c47"},
1603
+ {file = "ijson-3.3.0-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:87c727691858fd3a1c085d9980d12395517fcbbf02c69fbb22dede8ee03422da"},
1604
+ {file = "ijson-3.3.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0420c24e50389bc251b43c8ed379ab3e3ba065ac8262d98beb6735ab14844460"},
1605
+ {file = "ijson-3.3.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:8fdf3721a2aa7d96577970f5604bd81f426969c1822d467f07b3d844fa2fecc7"},
1606
+ {file = "ijson-3.3.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:891f95c036df1bc95309951940f8eea8537f102fa65715cdc5aae20b8523813b"},
1607
+ {file = "ijson-3.3.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ed1336a2a6e5c427f419da0154e775834abcbc8ddd703004108121c6dd9eba9d"},
1608
+ {file = "ijson-3.3.0-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f0c819f83e4f7b7f7463b2dc10d626a8be0c85fbc7b3db0edc098c2b16ac968e"},
1609
+ {file = "ijson-3.3.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:33afc25057377a6a43c892de34d229a86f89ea6c4ca3dd3db0dcd17becae0dbb"},
1610
+ {file = "ijson-3.3.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:7914d0cf083471856e9bc2001102a20f08e82311dfc8cf1a91aa422f9414a0d6"},
1611
+ {file = "ijson-3.3.0.tar.gz", hash = "sha256:7f172e6ba1bee0d4c8f8ebd639577bfe429dee0f3f96775a067b8bae4492d8a0"},
1612
+ ]
1613
+
1614
  [[package]]
1615
  name = "importlib-metadata"
1616
  version = "7.1.0"
 
1898
 
1899
  [[package]]
1900
  name = "litellm"
1901
+ version = "1.40.26"
1902
  description = "Library to easily interface with LLM API providers"
1903
  optional = false
1904
  python-versions = "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,>=3.8"
1905
  files = [
1906
+ {file = "litellm-1.40.26-py3-none-any.whl", hash = "sha256:5daedec00a3a8e32f55b3099190ccd9d550177f6e516823002831e6620ae771c"},
1907
+ {file = "litellm-1.40.26.tar.gz", hash = "sha256:4dfd4ca3eb50a62600e60303c4975ba9fe7c52d07882d0d2b6bad2d474d88758"},
1908
  ]
1909
 
1910
  [package.dependencies]
1911
  aiohttp = "*"
1912
  click = "*"
1913
+ ijson = "*"
1914
  importlib-metadata = ">=6.8.0"
1915
  jinja2 = ">=3.1.2,<4.0.0"
1916
  openai = ">=1.27.0"
1917
+ pydantic = ">=2.0.0,<3.0.0"
1918
  python-dotenv = ">=0.2.0"
1919
  requests = ">=2.31.0,<3.0.0"
1920
+ tiktoken = ">=0.7.0"
1921
  tokenizers = "*"
1922
 
1923
  [package.extras]
 
3967
  [metadata]
3968
  lock-version = "2.0"
3969
  python-versions = "^3.11"
3970
+ content-hash = "86b3d843ec602af91f686b93bed8ac01561e4eaca2eda509a4fcaeffcca5ad6b"
pyproject.toml CHANGED
@@ -12,7 +12,7 @@ google-cloud-secret-manager = "^2.20.0"
12
  google-generativeai = "^0.5.4"
13
  gradio = "^4.32.1"
14
  lingua-language-detector = "^2.0.2"
15
- litellm = "^1.39.5"
16
 
17
  [tool.poetry-auto-export]
18
  output = "requirements.txt"
 
12
  google-generativeai = "^0.5.4"
13
  gradio = "^4.32.1"
14
  lingua-language-detector = "^2.0.2"
15
+ litellm = "^1.40.26"
16
 
17
  [tool.poetry-auto-export]
18
  output = "requirements.txt"
requirements.txt CHANGED
@@ -53,6 +53,7 @@ httptools==0.6.1 ; python_version >= "3.11" and python_version < "4.0"
53
  httpx==0.27.0 ; python_version >= "3.11" and python_version < "4.0"
54
  huggingface-hub==0.23.2 ; python_version >= "3.11" and python_version < "4.0"
55
  idna==3.7 ; python_version >= "3.11" and python_version < "4.0"
 
56
  importlib-metadata==7.1.0 ; python_version >= "3.11" and python_version < "4.0"
57
  importlib-resources==6.4.0 ; python_version >= "3.11" and python_version < "4.0"
58
  jinja2==3.1.4 ; python_version >= "3.11" and python_version < "4.0"
@@ -60,7 +61,7 @@ jsonschema-specifications==2023.12.1 ; python_version >= "3.11" and python_versi
60
  jsonschema==4.22.0 ; python_version >= "3.11" and python_version < "4.0"
61
  kiwisolver==1.4.5 ; python_version >= "3.11" and python_version < "4.0"
62
  lingua-language-detector==2.0.2 ; python_version >= "3.11" and python_version < "4.0"
63
- litellm==1.39.5 ; python_version >= "3.11" and python_version < "4.0"
64
  markdown-it-py==3.0.0 ; python_version >= "3.11" and python_version < "4.0"
65
  markupsafe==2.1.5 ; python_version >= "3.11" and python_version < "4.0"
66
  matplotlib==3.9.0 ; python_version >= "3.11" and python_version < "4.0"
 
53
  httpx==0.27.0 ; python_version >= "3.11" and python_version < "4.0"
54
  huggingface-hub==0.23.2 ; python_version >= "3.11" and python_version < "4.0"
55
  idna==3.7 ; python_version >= "3.11" and python_version < "4.0"
56
+ ijson==3.3.0 ; python_version >= "3.11" and python_version < "4.0"
57
  importlib-metadata==7.1.0 ; python_version >= "3.11" and python_version < "4.0"
58
  importlib-resources==6.4.0 ; python_version >= "3.11" and python_version < "4.0"
59
  jinja2==3.1.4 ; python_version >= "3.11" and python_version < "4.0"
 
61
  jsonschema==4.22.0 ; python_version >= "3.11" and python_version < "4.0"
62
  kiwisolver==1.4.5 ; python_version >= "3.11" and python_version < "4.0"
63
  lingua-language-detector==2.0.2 ; python_version >= "3.11" and python_version < "4.0"
64
+ litellm==1.40.26 ; python_version >= "3.11" and python_version < "4.0"
65
  markdown-it-py==3.0.0 ; python_version >= "3.11" and python_version < "4.0"
66
  markupsafe==2.1.5 ; python_version >= "3.11" and python_version < "4.0"
67
  matplotlib==3.9.0 ; python_version >= "3.11" and python_version < "4.0"
response.py CHANGED
@@ -77,13 +77,7 @@ def get_responses(prompt: str, category: str, source_lang: str,
77
  instruction = get_instruction(category, model, source_lang, target_lang)
78
  try:
79
  # TODO(#1): Allow user to set configuration.
80
- response = model.completion(messages=[{
81
- "role": "system",
82
- "content": instruction
83
- }, {
84
- "role": "user",
85
- "content": prompt
86
- }])
87
  create_history(category, model.name, instruction, prompt, response)
88
  responses.append(response)
89
 
 
77
  instruction = get_instruction(category, model, source_lang, target_lang)
78
  try:
79
  # TODO(#1): Allow user to set configuration.
80
+ response = model.completion(instruction, prompt)
 
 
 
 
 
 
81
  create_history(category, model.name, instruction, prompt, response)
82
  responses.append(response)
83