韩宇 commited on
Commit
c95e297
·
1 Parent(s): 4dc3137
omagent_core/models/llms/azure_gpt.py CHANGED
@@ -1,10 +1,11 @@
1
  import os
2
  import sysconfig
3
  from datetime import datetime
4
- from typing import Any, Dict, List
5
 
6
  import geocoder
7
  from openai import AsyncAzureOpenAI, AzureOpenAI
 
8
 
9
  from ...utils.general import encode_image
10
  from ...utils.registry import registry
@@ -24,15 +25,59 @@ Operating System: {}"""
24
  @registry.register_llm()
25
  class AzureGPTLLM(BaseLLM):
26
  model_id: str
27
- vision: bool = False
28
  endpoint: str
29
  api_key: str
30
  api_version: str = "2024-02-15-preview"
31
- temperature: float = 1.0
32
- max_tokens: int = 2048
33
- use_default_sys_prompt: bool = True
34
- response_format: str = "text"
35
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  class Config:
37
  """Configuration for this pydantic object."""
38
 
 
1
  import os
2
  import sysconfig
3
  from datetime import datetime
4
+ from typing import Any, Dict, List, Optional, Union
5
 
6
  import geocoder
7
  from openai import AsyncAzureOpenAI, AzureOpenAI
8
+ from pydantic import Field
9
 
10
  from ...utils.general import encode_image
11
  from ...utils.registry import registry
 
25
  @registry.register_llm()
26
  class AzureGPTLLM(BaseLLM):
27
  model_id: str
 
28
  endpoint: str
29
  api_key: str
30
  api_version: str = "2024-02-15-preview"
31
+ model_id: str = Field(
32
+ default=os.getenv("MODEL_ID", "gpt-4o"), description="The model id of openai"
33
+ )
34
+ vision: bool = Field(default=False, description="Whether the model supports vision")
35
+ endpoint: str = Field(
36
+ default=os.getenv("ENDPOINT", "https://api.openai.com/v1"),
37
+ description="The endpoint of LLM service",
38
+ )
39
+ api_key: str = Field(
40
+ default=os.getenv("API_KEY"), description="The api key of openai"
41
+ )
42
+ temperature: float = Field(default=1.0, description="The temperature of LLM")
43
+ top_p: float = Field(
44
+ default=1.0,
45
+ description="The top p of LLM, controls diversity of responses. Should not be used together with temperature - use either temperature or top_p but not both",
46
+ )
47
+ stream: bool = Field(default=False, description="Whether to stream the response")
48
+ max_tokens: int = Field(default=2048, description="The max tokens of LLM")
49
+ use_default_sys_prompt: bool = Field(
50
+ default=True, description="Whether to use the default system prompt"
51
+ )
52
+ response_format: Optional[Union[dict, str]] = Field(default='text', description="The response format of openai")
53
+ n: int = Field(default=1, description="The number of responses to generate")
54
+ frequency_penalty: float = Field(
55
+ default=0, description="The frequency penalty of LLM, -2 to 2"
56
+ )
57
+ logit_bias: Optional[dict] = Field(
58
+ default=None, description="The logit bias of LLM"
59
+ )
60
+ logprobs: bool = Field(default=False, description="The logprobs of LLM")
61
+ top_logprobs: Optional[int] = Field(
62
+ default=None,
63
+ description="The top logprobs of LLM, logprobs must be set to true if this parameter is used",
64
+ )
65
+ stop: Union[str, List[str], None] = Field(
66
+ default='',
67
+ description="Specifies stop sequences that will halt text generation, can be string or list of strings",
68
+ )
69
+ stream_options: Optional[dict] = Field(
70
+ default=None,
71
+ description="Configuration options for streaming responses when stream=True",
72
+ )
73
+ tools: Optional[List[dict]] = Field(
74
+ default=None,
75
+ description="A list of function tools (max 128) that the model can call, each requiring a type, name and optional description/parameters defined in JSON Schema format.",
76
+ )
77
+ tool_choice: Optional[str] = Field(
78
+ default="none",
79
+ description="Controls which tool (if any) is called by the model: 'none', 'auto', 'required', or a specific tool.",
80
+ )
81
  class Config:
82
  """Configuration for this pydantic object."""
83