Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(): fix prompt and attribute settings #250

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions agents/property.json
Original file line number Diff line number Diff line change
Expand Up @@ -1841,9 +1841,9 @@
"greeting": "ASTRA agent connected. How can i help you today?",
"max_memory_length": 10,
"max_output_tokens": 512,
"model": "gemini-1.0-pro-latest",
"model": "gemini-1.5-flash",
"prompt": "",
"temperature": 0.1,
"temperature": 1.0,
"top_k": 40,
"top_p": 0.95
}
Expand Down Expand Up @@ -2375,4 +2375,4 @@
}
]
}
}
}
4 changes: 2 additions & 2 deletions agents/property.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -1961,9 +1961,9 @@
"greeting": "ASTRA agent connected. How can i help you today?",
"max_memory_length": 10,
"max_output_tokens": 512,
"model": "gemini-1.0-pro-latest",
"model": "gemini-1.5-flash",
"prompt": "",
"temperature": 0.1,
"temperature": 1.0,
"top_k": 40,
"top_p": 0.95
}
Expand Down
8 changes: 4 additions & 4 deletions agents/ten_packages/extension/gemini_llm_python/gemini_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def default_config(cls):
return cls(
api_key="",
max_output_tokens=512,
model="gemini-1.0-pro-latest",
model="gemini-1.5-flash",
prompt="You are a voice assistant who talks in a conversational way and can chat with me like my friends. I will speak to you in English or Chinese, and you will answer in the corrected and improved version of my text with the language I use. Don’t talk like a robot, instead I would like you to talk like a real human with emotions. I will use your answer for text-to-speech, so don’t return me any meaningless characters. I want you to be helpful, when I’m asking you for advice, give me precise, practical and useful advice instead of being vague. When giving me a list of options, express the options in a narrative way instead of bullet points.",
temperature=0.1,
temperature=1.0,
top_k=40,
top_p=0.95,
)
Expand All @@ -36,12 +36,12 @@ class GeminiLLM:
def __init__(self, config: GeminiLLMConfig):
self.config = config
genai.configure(api_key=self.config.api_key)
self.model = genai.GenerativeModel(self.config.model)
self.model = genai.GenerativeModel(model_name=self.config.model, system_instruction=self.config.prompt)

def get_chat_completions_stream(self, messages: List[Dict[str, str]]):
try:
chat = self.model.start_chat(history=messages[0:-1])
response = chat.send_message((self.config.prompt, messages[-1].get("parts")),
response = chat.send_message(messages[-1].get("parts"),
generation_config=genai.types.GenerationConfig(
max_output_tokens=self.config.max_output_tokens,
temperature=self.config.temperature,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ def on_start(self, ten: TenEnv) -> None:
try:
val = ten.get_property_string(key)
if val:
gemini_llm_config.key = val
setattr(gemini_llm_config, key, val)
except Exception as e:
logger.warning(f"get_property_string optional {key} failed, err: {e}")

for key in [PROPERTY_TEMPERATURE, PROPERTY_TOP_P]:
try:
gemini_llm_config.key = float(ten.get_property_float(key))
setattr(gemini_llm_config, key, float(ten.get_property_float(key)))
except Exception as e:
logger.warning(f"get_property_float optional {key} failed, err: {e}")

for key in [PROPERTY_MAX_OUTPUT_TOKENS, PROPERTY_TOP_K]:
try:
gemini_llm_config.key = int(ten.get_property_int(key))
setattr(gemini_llm_config, key, int(ten.get_property_int(key)))
except Exception as e:
logger.warning(f"get_property_int optional {key} failed, err: {e}")

Expand Down