gemba 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
gemba/gpt_api.py CHANGED
@@ -89,6 +89,12 @@ class GptApi:
89
89
  def request_api(self, prompt, model, temperature=0, max_tokens=None):
90
90
  if temperature > 10:
91
91
  return []
92
+
93
+ # Add maximum token limit
94
+ MAX_TOKENS_LIMIT = 4000 # Adjust this based on your model's context window
95
+ if max_tokens and max_tokens > MAX_TOKENS_LIMIT:
96
+ print(f"Reached maximum token limit of {MAX_TOKENS_LIMIT}", file=sys.stderr)
97
+ return []
92
98
 
93
99
  while True:
94
100
  try:
@@ -123,8 +129,12 @@ class GptApi:
123
129
  print(colored(f"Increasing max tokens to fit answers.", "red") + colored(answer, "blue"), file=sys.stderr)
124
130
  print(f"Finish reason: {choice.finish_reason}", file=sys.stderr)
125
131
  if max_tokens is None:
132
+ max_tokens = 500 # Set initial max_tokens if None
133
+ new_max_tokens = max_tokens + 200
134
+ if new_max_tokens > MAX_TOKENS_LIMIT:
135
+ print(f"Would exceed maximum token limit of {MAX_TOKENS_LIMIT}", file=sys.stderr)
126
136
  return []
127
- return self.request_api(prompt, model, temperature=temperature, max_tokens=max_tokens + 200)
137
+ return self.request_api(prompt, model, temperature=temperature, max_tokens=new_max_tokens)
128
138
 
129
139
  answers.append({
130
140
  "answer": answer,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: gemba
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: GEMBA — GPT Estimation Metric Based Assessment
5
5
  Project-URL: Homepage, https://github.com/joelniklaus/gemba
6
6
  Author-email: Joel Niklaus <joel@niklaus.ai>
@@ -50,7 +50,7 @@ Install the gemba package with `pip install gemba` and use the following code:
50
50
  from gemba import get_gemba_scores
51
51
 
52
52
  source = ["Hello, how are you?", "I am fine, thank you.", "I am not fine, thank you."]
53
- hypothesis = ["Hallo, wie geht es dir?", "Ich bin gut, danke.", "Ich bin Adolf, wer bist du?"]
53
+ hypothesis = ["Hallo, wie geht es dir?", "Ich bin gut, danke.", "Ich bin Joel, wer bist du?"]
54
54
  source_lang = "en"
55
55
  target_lang = "de"
56
56
 
@@ -2,13 +2,13 @@ gemba/__init__.py,sha256=0ZuEumkUMWPI5wQMY7OxLolELI9GYYlup-iJw8SwBgc,67
2
2
  gemba/gemba_da.py,sha256=YCOKKP7kZBL9e1d44Zr7aTa23BqLFvh4KDOfbNSMgOU,2360
3
3
  gemba/gemba_esa.py,sha256=nBCeFjrS24wXLOcAXHRSmZFYJSkUzRS4hfp2LEqYwp8,4461
4
4
  gemba/gemba_mqm_utils.py,sha256=qiIdJv7IDx0eeqpsTCHMoUeo8EUOhG6k-YfrzkRfxyw,9612
5
- gemba/gpt_api.py,sha256=Igp8uQn6chKL1QWFMqKP2VR9Fbzxm8Xk83ELxk5NfM8,6671
5
+ gemba/gpt_api.py,sha256=mucb4iGRk8ZHMHx9uSQpaFodPgMP_r5sjkvQwot8j3M,7245
6
6
  gemba/mtme_tools.py,sha256=xpLxCzfnLHFIxsq_LOi1Lpb-gkyFGYqFXiq9y6O315Q,4667
7
7
  gemba/prompt.py,sha256=AuPBhO2OBL3EB5I37p-GX10sx29gRw35xFAnB3bqtII,7578
8
8
  gemba/scores.py,sha256=FmmBJ-ds-abExphcVUw9qaPMnKttPWobuXNwZKLAtEs,4388
9
9
  gemba/testset.py,sha256=tDvi6xQIBXrODg02WWINrYg9jNQqruCmhBrxe9AaK48,1926
10
10
  gemba/utils.py,sha256=Re5uW5dcFj3ITWIGpxjXdAKNDKQ7i4H-Tr_s74SQgmk,4311
11
- gemba-0.1.0.dist-info/METADATA,sha256=9_jYmIPKmAz5cmPn-fTUB7a5xHLbYrlTXpdzhEYaSSw,3692
12
- gemba-0.1.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
13
- gemba-0.1.0.dist-info/licenses/LICENSE.md,sha256=XkNv-P-7d9hgciDpvOIMiRXYYAEP7rbB6-9ahWiOmzk,20137
14
- gemba-0.1.0.dist-info/RECORD,,
11
+ gemba-0.1.1.dist-info/METADATA,sha256=crV8OU2-e1rixB9gfFGjvidoqQLlX5kRZ23sVKqLhqc,3691
12
+ gemba-0.1.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
13
+ gemba-0.1.1.dist-info/licenses/LICENSE.md,sha256=XkNv-P-7d9hgciDpvOIMiRXYYAEP7rbB6-9ahWiOmzk,20137
14
+ gemba-0.1.1.dist-info/RECORD,,
File without changes