update code due to failed unittests

This commit is contained in:
better629 2024-02-03 13:33:02 +08:00
parent 2eeb9556f5
commit f2dbb51094
4 changed files with 14 additions and 6 deletions

View file

@ -16,5 +16,5 @@ def LLM(llm_config: Optional[LLMConfig] = None, context: Context = None) -> Base
"""get the default llm provider if name is None"""
ctx = context or Context()
if llm_config is not None:
ctx.llm_with_cost_manager_from_llm_config(llm_config)
return ctx.llm_with_cost_manager_from_llm_config(llm_config)
return ctx.llm()

View file

@ -2,6 +2,8 @@
# -*- coding: utf-8 -*-
# @Desc : Google Gemini LLM from https://ai.google.dev/tutorials/python_quickstart
from typing import Optional, Union
import google.generativeai as genai
from google.ai import generativelanguage as glm
from google.generativeai.generative_models import GenerativeModel
@ -58,7 +60,7 @@ class GeminiLLM(BaseLLM):
def __init_gemini(self, config: LLMConfig):
genai.configure(api_key=config.api_key)
def _user_msg(self, msg: str) -> dict[str, str]:
def _user_msg(self, msg: str, images: Optional[Union[str, list[str]]] = None) -> dict[str, str]:
# Not to change BaseLLM default functions but update with Gemini's conversation format.
# You should follow the format.
return {"role": "user", "parts": [msg]}