Skip to content

Commit

Permalink
refactor: override an undefined system instruction when supported as …
Browse files Browse the repository at this point in the history
…variables
  • Loading branch information
zimeg committed Sep 28, 2024
1 parent c7dad78 commit 66c0e74
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions ai/providers/vertexai.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,19 @@ def get_models(self) -> dict:

def generate_response(self, prompt: str, system_content: str) -> str:
try:
system_instruction = None
if self.MODELS[self.current_model]["system_instruction_supported"]:
self.client = vertexai.generative_models.GenerativeModel(
model_name=self.current_model,
generation_config={
"max_output_tokens": self.MODELS[self.current_model]["max_tokens"],
},
system_instruction=system_content,
)
system_instruction = system_content
else:
prompt = system_content + "\n" + prompt
self.client = vertexai.generative_models.GenerativeModel(
model_name=self.current_model,
generation_config={
"max_output_tokens": self.MODELS[self.current_model]["max_tokens"],
},
)

self.client = vertexai.generative_models.GenerativeModel(
model_name=self.current_model,
generation_config={
"max_output_tokens": self.MODELS[self.current_model]["max_tokens"],
},
system_instruction=system_instruction,
)
response = self.client.generate_content(
contents=prompt,
)
Expand Down

0 comments on commit 66c0e74

Please sign in to comment.