CosmosShadow / GeneralAgent

A python native agent framework
348 stars 44 forks source link

Do not support Azure Open AI. #8

Closed JunweiDuan closed 3 weeks ago

JunweiDuan commented 3 weeks ago

Traceback (most recent call last): File "D:\Users--\AppData\Roaming\Python\Python311\site-packages\GeneralAgent\agent\agent.py", line 310, in _llm_and_parse_output for token in response: File "D:\Users--\AppData\Roaming\Python\Python311\site-packages\GeneralAgent\skills\llm_inference.py", line 121, in _llm_inference_with_stream raise ValueError('LLM(Large Languate Model) error, Please check your key or base_url, or network') ValueError: LLM(Large Languate Model) error, Please check your key or base_url, or network

Okysu commented 3 weeks ago

2 可以查看这个PR

如果自己有服务器可以使用进行对齐one-api 或者可以使用Cloud flare Workers的方法,查看这个Repcf-openai-azure-proxy](https://github.com/haibbo/cf-openai-azure-proxy) 但第二个repo更新较慢,我当时使用的时候只支持chat模型的转发,不支持向量模型和asr、tts模型以及多模态的4v,4o模型。

JunweiDuan commented 3 weeks ago

我后来自己改了下支持Azure Open AI了:主要是两个API不兼容,Azure需要版本号

def _get_openai_client(api_key=None, base_url=None): from openai import AzureOpenAI import os if api_key is None and 'OPENAI_API_KEY' not in os.environ: raise ValueError('Please set OPENAI_API_KEY in environment') api_key = api_key or os.environ['OPENAI_API_KEY'] base_url = base_url or os.environ.get('OPENAI_API_BASE', 'https://api.openai.com/v1') api_version = os.environ.get('OPENAI_API_VERSION') client = AzureOpenAI(api_key=api_key, azure_endpoint=base_url, max_retries=3, api_version=api_version) return client

CosmosShadow commented 3 weeks ago

The latest version support Azure.