File "/Users/kaushikbokka/apps/leather/language-models/venv/lib/python3.8/site-packages/langchain_core/language_models/chat_models.py", line 556, in generate_prompt return self.generate(prompt_messages, stop=stop, callbacks=callbacks, **kwargs) File "/Users/kaushikbokka/apps/leather/language-models/venv/lib/python3.8/site-packages/langchain_core/language_models/chat_models.py", line 417, in generate raise e File "/Users/kaushikbokka/apps/leather/language-models/venv/lib/python3.8/site-packages/langchain_core/language_models/chat_models.py", line 407, in generate self._generate_with_cache( File "/Users/kaushikbokka/apps/leather/language-models/venv/lib/python3.8/site-packages/langchain_core/language_models/chat_models.py", line 626, in _generate_with_cache result = self._generate( File "/Users/kaushikbokka/apps/leather/language-models/venv/lib/python3.8/site-packages/langchain_core/language_models/chat_models.py", line 910, in _generate output_str = self._call(messages, stop=stop, run_manager=run_manager, **kwargs) File "/Users/kaushikbokka/apps/leather/language-models/venv/lib/python3.8/site-packages/portkey_ai/llms/langchain/chat.py", line 173, in _call return message.get("content", "") if message else "" AttributeError: 'ChatCompletionMessage' object has no attribute 'get'
class BaseChain(ABC): def __init__( self, temperature: Union[int, float] = 1, max_tokens: int = 256, llm: Optional[BaseLLM] = None, system_message: str = "", human_message: str = "", virtual_key: str = "azure-openai-ce-948b68", config: Optional[Union[Mapping, str]] = None, retry_count: Optional[int] = None, cache: Optional[str] = None, cache_force_refresh: Optional[str] = None, cache_age: Optional[int] = None, custom_metadata: Optional[str] = None, ): self._system_message = system_message self._human_message = human_message if llm is not None: self._llm = llm else: if "PORTKEY_API_KEY" not in os.environ: raise ValueError("PORTKEY_API_KEY env variable not set") PORTKEY_API_KEY = os.getenv("PORTKEY_API_KEY") if custom_metadata is None: custom_metadata = {"chain": self.tag.replace("_chain", "")} self._llm_kwargs = { "temperature": temperature, "max_tokens": max_tokens, "api_key": PORTKEY_API_KEY, "config": config, "virtual_key": virtual_key, "retry_count": retry_count, "cache": cache, "cache_force_refresh": cache_force_refresh, "cache_age": cache_age, "custom_metadata": custom_metadata, # "request_timeout": 1200, } self._llm = ChatPortkey(**self._llm_kwargs)
portkey_headers = createHeaders( api_key=PORTKEY_API_KEY, config=config ) llm = ChatOpenAI(api_key="X", base_url=PORTKEY_GATEWAY_URL, default_headers=portkey_headers) llm.invoke("What is the meaning of life, universe and everything?")