Skip to content

Commit 7a7d4bc

Browse files
committed
fix gemini issue
1 parent 9ae98c7 commit 7a7d4bc

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

patchwork/common/client/llm/google.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def is_prompt_supported(
108108
model=model,
109109
contents=chat,
110110
config=CountTokensConfig(
111-
system_instructions=system,
111+
system_instruction=system,
112112
),
113113
)
114114
token_count = token_response.total_tokens
@@ -181,15 +181,15 @@ def chat_completion(
181181
config=GenerateContentConfig(
182182
system_instruction=system_content,
183183
safety_settings=self.__SAFETY_SETTINGS,
184-
**generation_dict,
184+
**NotGiven.remove_not_given(generation_dict),
185185
),
186186
)
187187
return self.__google_response_to_openai_response(response, model)
188188

189189
@staticmethod
190190
def __google_response_to_openai_response(google_response: GenerateContentResponse, model: str) -> ChatCompletion:
191191
choices = []
192-
for candidate in google_response.candidates:
192+
for index, candidate in enumerate(google_response.candidates):
193193
# note that instead of system, from openai, its model, from google.
194194
parts = [part.text or part.inline_data for part in candidate.content.parts]
195195

@@ -202,7 +202,7 @@ def __google_response_to_openai_response(google_response: GenerateContentRespons
202202

203203
choice = Choice(
204204
finish_reason=finish_reason_map.get(candidate.finish_reason, "stop"),
205-
index=candidate.index,
205+
index=index,
206206
message=ChatCompletionMessage(
207207
content="\n".join(parts),
208208
role="assistant",

patchwork/steps/ReadEmail/ReadEmail.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
from patchwork.step import Step
1414
from patchwork.steps.ReadEmail.typed import ReadEmailInputs, ReadEmailOutputs
1515

16+
1617
class InnerParsedHeader(BaseModel):
1718
message_id: list[str] = Field(alias="message-id")
1819

20+
1921
class ParsedHeader(BaseModel):
2022
subject: str = ""
2123
from_: str = Field(alias="from", default_factory=str)
@@ -91,10 +93,12 @@ def run(self) -> dict:
9193
for content_transfer_encoding in attachment.content_header.content_transfer_encoding:
9294
content = self.__decode(content_transfer_encoding, content)
9395
f.write(content)
94-
rv["attachments"].append(dict(
95-
path=str(file_path),
96-
# content=content.decode(),
97-
))
96+
rv["attachments"].append(
97+
dict(
98+
path=str(file_path),
99+
# content=content.decode(),
100+
)
101+
)
98102

99103
for body in email_data.body:
100104
rv["body"] += body.content

patchwork/steps/SendEmail/SendEmail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def run(self) -> dict:
2727
msg["From"] = self.sender_email
2828
msg["To"] = self.recipient_email
2929
if self.reply_message_id is not None:
30-
msg.add_header('Reference', self.reply_message_id)
31-
msg.add_header('In-Reply-To', self.reply_message_id)
30+
msg.add_header("Reference", self.reply_message_id)
31+
msg.add_header("In-Reply-To", self.reply_message_id)
3232

3333
# TODO: support smtp without ssl
3434
with smtplib.SMTP_SSL(self.smtp_host, self.smtp_port) as smtp_server:

patchwork/steps/SimplifiedLLMOnce/typed.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class SimplifiedLLMOnceInputs(__SimplifiedLLMOncePBInputsRequired, total=False):
3838
google_api_key: Annotated[
3939
str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key"])
4040
]
41+
file: Annotated[str, StepTypeConfig(is_path=True)]
4142

4243

4344
class SimplifiedLLMOnceOutputs(TypedDict):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "patchwork-cli"
3-
version = "0.0.99.dev2"
3+
version = "0.0.99.dev3"
44
description = ""
55
authors = ["patched.codes"]
66
license = "AGPL"

0 commit comments

Comments
 (0)