ghostdrive1 commited on
Commit
2cd72b0
·
verified ·
1 Parent(s): 69e26e5

Upload folder using huggingface_hub

Browse files
src/agentscope/credential/__init__.py CHANGED
@@ -9,6 +9,11 @@ from ._gemini import GeminiCredential
9
  from ._moonshot import MoonshotCredential
10
  from ._ollama import OllamaCredential
11
  from ._openai import OpenAICredential
 
 
 
 
 
12
  from ._xai import XAICredential
13
  from ._factory import CredentialFactory
14
 
@@ -19,9 +24,12 @@ __all__ = [
19
  "DashScopeCredential",
20
  "DeepSeekCredential",
21
  "GeminiCredential",
 
22
  "MoonshotCredential",
 
23
  "OllamaCredential",
24
  "OpenAICredential",
 
25
  "XAICredential",
26
  "CredentialFactory",
27
  ]
 
9
  from ._moonshot import MoonshotCredential
10
  from ._ollama import OllamaCredential
11
  from ._openai import OpenAICredential
12
+ from ._openai_compat import (
13
+ GroqCredential,
14
+ NvidiaNimCredential,
15
+ OpenRouterCredential,
16
+ )
17
  from ._xai import XAICredential
18
  from ._factory import CredentialFactory
19
 
 
24
  "DashScopeCredential",
25
  "DeepSeekCredential",
26
  "GeminiCredential",
27
+ "GroqCredential",
28
  "MoonshotCredential",
29
+ "NvidiaNimCredential",
30
  "OllamaCredential",
31
  "OpenAICredential",
32
+ "OpenRouterCredential",
33
  "XAICredential",
34
  "CredentialFactory",
35
  ]
src/agentscope/credential/_factory.py CHANGED
@@ -11,6 +11,11 @@ from ._gemini import GeminiCredential
11
  from ._moonshot import MoonshotCredential
12
  from ._ollama import OllamaCredential
13
  from ._openai import OpenAICredential
 
 
 
 
 
14
  from ._xai import XAICredential
15
  from ._base import CredentialBase
16
 
@@ -38,9 +43,12 @@ class CredentialFactory:
38
  DashScopeCredential,
39
  DeepSeekCredential,
40
  GeminiCredential,
 
41
  MoonshotCredential,
 
42
  OllamaCredential,
43
  OpenAICredential,
 
44
  XAICredential,
45
  ]
46
  _adapter: TypeAdapter[CredentialBase] | None = None
 
11
  from ._moonshot import MoonshotCredential
12
  from ._ollama import OllamaCredential
13
  from ._openai import OpenAICredential
14
+ from ._openai_compat import (
15
+ GroqCredential,
16
+ NvidiaNimCredential,
17
+ OpenRouterCredential,
18
+ )
19
  from ._xai import XAICredential
20
  from ._base import CredentialBase
21
 
 
43
  DashScopeCredential,
44
  DeepSeekCredential,
45
  GeminiCredential,
46
+ GroqCredential,
47
  MoonshotCredential,
48
+ NvidiaNimCredential,
49
  OllamaCredential,
50
  OpenAICredential,
51
+ OpenRouterCredential,
52
  XAICredential,
53
  ]
54
  _adapter: TypeAdapter[CredentialBase] | None = None
src/agentscope/credential/_openai_compat.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """OpenAI-compatible credentials (Groq, OpenRouter, NVIDIA NIM)."""
3
+ from typing import Literal
4
+
5
+ from pydantic import ConfigDict, Field
6
+
7
+ from ._openai import OpenAICredential
8
+
9
+
10
+ class GroqCredential(OpenAICredential):
11
+ """The Groq credential model."""
12
+
13
+ model_config = ConfigDict(
14
+ title="Groq API",
15
+ )
16
+
17
+ type: Literal["groq_credential"] = "groq_credential"
18
+ """The credential type."""
19
+
20
+ base_url: str | None = Field(
21
+ default="https://api.groq.com/openai/v1",
22
+ description="The base URL for the Groq API.",
23
+ )
24
+ """Custom base URL for the Groq API."""
25
+
26
+
27
+ class OpenRouterCredential(OpenAICredential):
28
+ """The OpenRouter credential model."""
29
+
30
+ model_config = ConfigDict(
31
+ title="OpenRouter API",
32
+ )
33
+
34
+ type: Literal["openrouter_credential"] = "openrouter_credential"
35
+ """The credential type."""
36
+
37
+ base_url: str | None = Field(
38
+ default="https://openrouter.ai/api/v1",
39
+ description="The base URL for the OpenRouter API.",
40
+ )
41
+ """Custom base URL for the OpenRouter API."""
42
+
43
+
44
+ class NvidiaNimCredential(OpenAICredential):
45
+ """The NVIDIA NIM credential model."""
46
+
47
+ model_config = ConfigDict(
48
+ title="NVIDIA NIM API",
49
+ )
50
+
51
+ type: Literal["nvidia_nim_credential"] = "nvidia_nim_credential"
52
+ """The credential type."""
53
+
54
+ base_url: str | None = Field(
55
+ default="https://integrate.api.nvidia.com/v1",
56
+ description="The base URL for the NVIDIA NIM API.",
57
+ )
58
+ """Custom base URL for the NVIDIA NIM API."""