davidkhala.ai 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- davidkhala/ai/agent/dify/ops/console/plugin.py +1 -1
- davidkhala/ai/agent/dify/plugins/popular.py +4 -1
- davidkhala/ai/ali/dashscope.py +4 -8
- davidkhala/ai/api/__init__.py +2 -1
- davidkhala/ai/mistral/__init__.py +33 -0
- davidkhala/ai/model/__init__.py +44 -0
- davidkhala/ai/model/chat.py +19 -0
- davidkhala/ai/openai/__init__.py +24 -16
- davidkhala/ai/openai/azure.py +5 -4
- davidkhala/ai/openai/databricks.py +23 -0
- davidkhala/ai/openai/native.py +3 -2
- davidkhala/ai/openai/opik.py +10 -0
- davidkhala/ai/openrouter/__init__.py +1 -0
- davidkhala/ai/you.py +55 -0
- {davidkhala_ai-0.2.0.dist-info → davidkhala_ai-0.2.1.dist-info}/METADATA +5 -1
- {davidkhala_ai-0.2.0.dist-info → davidkhala_ai-0.2.1.dist-info}/RECORD +17 -12
- davidkhala/ai/model.py +0 -28
- {davidkhala_ai-0.2.0.dist-info → davidkhala_ai-0.2.1.dist-info}/WHEEL +0 -0
|
@@ -40,7 +40,7 @@ class ConsolePlugin(API):
|
|
|
40
40
|
return _
|
|
41
41
|
|
|
42
42
|
def get(self, *plugin_names: str) -> list[dict]:
|
|
43
|
-
"inspect installed plugins"
|
|
43
|
+
"""inspect installed plugins"""
|
|
44
44
|
url = f"{self.base_url}/list/installations/ids"
|
|
45
45
|
r = self.request(url, method="POST", json={
|
|
46
46
|
'plugin_ids': plugin_names,
|
davidkhala/ai/ali/dashscope.py
CHANGED
|
@@ -4,7 +4,7 @@ from http import HTTPStatus
|
|
|
4
4
|
from dashscope.api_entities.dashscope_response import DashScopeAPIResponse
|
|
5
5
|
|
|
6
6
|
from dashscope import Generation, TextEmbedding
|
|
7
|
-
from davidkhala.ai.model import AbstractClient
|
|
7
|
+
from davidkhala.ai.model import AbstractClient, MessageDict
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class ModelEnum(str, Enum):
|
|
@@ -21,11 +21,10 @@ class API(AbstractClient):
|
|
|
21
21
|
Unsupported to use international base_url "https://dashscope-intl.aliyuncs.com"
|
|
22
22
|
"""
|
|
23
23
|
|
|
24
|
-
model: ModelEnum
|
|
25
|
-
|
|
26
24
|
def __init__(self, api_key):
|
|
25
|
+
super().__init__()
|
|
27
26
|
self.api_key = api_key
|
|
28
|
-
|
|
27
|
+
self.model: ModelEnum|None = None
|
|
29
28
|
def as_embeddings(self, model=ModelEnum.EMBED):
|
|
30
29
|
super().as_embeddings(model)
|
|
31
30
|
|
|
@@ -44,10 +43,7 @@ class API(AbstractClient):
|
|
|
44
43
|
else:
|
|
45
44
|
kwargs['messages'] = [
|
|
46
45
|
*self.messages,
|
|
47
|
-
|
|
48
|
-
"role": "user",
|
|
49
|
-
'content': user_prompt
|
|
50
|
-
}
|
|
46
|
+
MessageDict(role='user',content=user_prompt),
|
|
51
47
|
]
|
|
52
48
|
# prompt 和 messages 是互斥的参数:如果你使用了 messages,就不要再传 prompt
|
|
53
49
|
r = Generation.call(
|
davidkhala/ai/api/__init__.py
CHANGED
|
@@ -8,7 +8,8 @@ from davidkhala.ai.model import AbstractClient
|
|
|
8
8
|
|
|
9
9
|
class API(AbstractClient, Request):
|
|
10
10
|
def __init__(self, api_key: str, base_url: str):
|
|
11
|
-
|
|
11
|
+
AbstractClient.__init__(self)
|
|
12
|
+
Request.__init__(self,{
|
|
12
13
|
"bearer": api_key
|
|
13
14
|
})
|
|
14
15
|
self.base_url = base_url + '/v1'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# https://github.com/mistralai/client-python
|
|
2
|
+
|
|
3
|
+
from davidkhala.ai.model import AbstractClient
|
|
4
|
+
from mistralai import Mistral, ChatCompletionResponse, ResponseFormat
|
|
5
|
+
from davidkhala.ai.model.chat import on_response
|
|
6
|
+
|
|
7
|
+
class Client(AbstractClient):
|
|
8
|
+
n = 1
|
|
9
|
+
|
|
10
|
+
def __init__(self, api_key: str):
|
|
11
|
+
self.api_key = api_key
|
|
12
|
+
self.client = Mistral(api_key=api_key)
|
|
13
|
+
self.model = "mistral-large-latest"
|
|
14
|
+
self.messages = []
|
|
15
|
+
|
|
16
|
+
def __enter__(self):
|
|
17
|
+
self.client.__enter__()
|
|
18
|
+
return self
|
|
19
|
+
|
|
20
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
21
|
+
return self.client.__exit__(exc_type, exc_val, exc_tb)
|
|
22
|
+
|
|
23
|
+
def chat(self, *user_prompt, **kwargs):
|
|
24
|
+
response: ChatCompletionResponse = self.client.chat.complete(
|
|
25
|
+
model=self.model,
|
|
26
|
+
messages=[
|
|
27
|
+
*self.messages,
|
|
28
|
+
*[{"content": m, "role": "user"} for m in user_prompt]
|
|
29
|
+
], stream=False, response_format=ResponseFormat(type='text'),
|
|
30
|
+
n=self.n,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
return on_response(response, self.n)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from abc import ABC
|
|
2
|
+
from typing import Protocol, TypedDict
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class MessageDict(TypedDict):
|
|
6
|
+
content: str | list
|
|
7
|
+
role: str
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ClientProtocol(Protocol):
|
|
11
|
+
api_key: str
|
|
12
|
+
base_url: str
|
|
13
|
+
model: str | None
|
|
14
|
+
messages: list[MessageDict] | None
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AbstractClient(ABC, ClientProtocol):
|
|
18
|
+
|
|
19
|
+
def __init__(self):
|
|
20
|
+
self.model = None
|
|
21
|
+
self.messages = []
|
|
22
|
+
|
|
23
|
+
def as_chat(self, model: str, sys_prompt: str = None):
|
|
24
|
+
self.model = model
|
|
25
|
+
if sys_prompt is not None:
|
|
26
|
+
self.messages = [MessageDict(role='system', content=sys_prompt)]
|
|
27
|
+
|
|
28
|
+
def as_embeddings(self, model: str):
|
|
29
|
+
self.model = model
|
|
30
|
+
|
|
31
|
+
def chat(self, *user_prompt, **kwargs):
|
|
32
|
+
...
|
|
33
|
+
|
|
34
|
+
def encode(self, *_input: str) -> list[list[float]]:
|
|
35
|
+
...
|
|
36
|
+
|
|
37
|
+
def connect(self):
|
|
38
|
+
...
|
|
39
|
+
|
|
40
|
+
def close(self):
|
|
41
|
+
...
|
|
42
|
+
|
|
43
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
44
|
+
self.close()
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from typing import Protocol, Any
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class MessageProtocol(Protocol):
|
|
5
|
+
content: str | Any
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ChoiceProtocol(Protocol):
|
|
9
|
+
message: MessageProtocol
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ChoicesAware(Protocol):
|
|
13
|
+
choices: list[ChoiceProtocol]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def on_response(response: ChoicesAware, n: int):
|
|
17
|
+
contents = [choice.message.content for choice in response.choices]
|
|
18
|
+
assert len(contents) == n
|
|
19
|
+
return contents
|
davidkhala/ai/openai/__init__.py
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
from typing import Union, Literal
|
|
1
|
+
from typing import Literal
|
|
3
2
|
|
|
4
|
-
from
|
|
3
|
+
from httpx import URL
|
|
4
|
+
from openai import OpenAI
|
|
5
5
|
|
|
6
6
|
from davidkhala.ai.model import AbstractClient
|
|
7
|
+
from davidkhala.ai.model.chat import on_response
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
class Client(AbstractClient):
|
|
10
|
-
client: OpenAI
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
def __init__(self, client: OpenAI):
|
|
12
|
+
super().__init__()
|
|
13
|
+
self.client:OpenAI = client
|
|
14
|
+
self.base_url:URL = client.base_url
|
|
15
|
+
self.api_key = client.api_key
|
|
16
|
+
self.encoding_format:Literal["float", "base64"] = "float"
|
|
17
|
+
self.n:int = 1
|
|
14
18
|
def connect(self):
|
|
15
|
-
|
|
19
|
+
try:
|
|
20
|
+
type(self).models.fget(self)
|
|
21
|
+
return True
|
|
22
|
+
except: # TODO make specific
|
|
23
|
+
return False
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def models(self):
|
|
27
|
+
return self.client.models.list()
|
|
16
28
|
|
|
17
29
|
def encode(self, *_input: str) -> list[list[float]]:
|
|
18
30
|
response = self.client.embeddings.create(
|
|
@@ -50,15 +62,11 @@ class Client(AbstractClient):
|
|
|
50
62
|
n=self.n,
|
|
51
63
|
**kwargs
|
|
52
64
|
)
|
|
53
|
-
contents = [choice.message.content for choice in response.choices]
|
|
54
|
-
assert len(contents) == self.n
|
|
55
|
-
return contents
|
|
56
65
|
|
|
57
|
-
|
|
66
|
+
return on_response(response, self.n)
|
|
67
|
+
|
|
68
|
+
def close(self):
|
|
58
69
|
self.client.close()
|
|
59
70
|
|
|
60
71
|
|
|
61
|
-
|
|
62
|
-
from opik.integrations.openai import track_openai
|
|
63
|
-
runpy.run_path('../opik.py')
|
|
64
|
-
return track_openai(instance)
|
|
72
|
+
|
davidkhala/ai/openai/azure.py
CHANGED
|
@@ -10,23 +10,24 @@ class AzureHosted(Client):
|
|
|
10
10
|
raise ValueError('Web search options not supported in any models of Azure AI Foundry')
|
|
11
11
|
return super().chat(*user_prompt, **kwargs)
|
|
12
12
|
|
|
13
|
+
|
|
13
14
|
class ModelDeploymentClient(AzureHosted):
|
|
14
15
|
def __init__(self, key, deployment):
|
|
15
|
-
|
|
16
|
+
super().__init__(AzureOpenAI(
|
|
16
17
|
api_version="2024-12-01-preview", # mandatory
|
|
17
18
|
azure_endpoint=f"https://{deployment}.cognitiveservices.azure.com/",
|
|
18
19
|
api_key=key,
|
|
19
|
-
)
|
|
20
|
+
))
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
@deprecated("Azure Open AI is deprecated. Please migrate to Microsoft Foundry")
|
|
23
24
|
class OpenAIClient(AzureHosted):
|
|
24
25
|
|
|
25
26
|
def __init__(self, api_key, project):
|
|
26
|
-
|
|
27
|
+
super().__init__(OpenAI(
|
|
27
28
|
base_url=f"https://{project}.openai.azure.com/openai/v1/",
|
|
28
29
|
api_key=api_key,
|
|
29
|
-
)
|
|
30
|
+
))
|
|
30
31
|
|
|
31
32
|
def as_chat(self, model="gpt-oss-120b", sys_prompt: str = None):
|
|
32
33
|
super().as_chat(model, sys_prompt)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from openai import OpenAI
|
|
2
|
+
from davidkhala.ai.openai import Client as BaseClient
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Client(BaseClient):
|
|
6
|
+
def __init__(self, host: str, token: str):
|
|
7
|
+
super().__init__(OpenAI(
|
|
8
|
+
base_url=f"https://{host}/serving-endpoints",
|
|
9
|
+
api_key=token
|
|
10
|
+
))
|
|
11
|
+
|
|
12
|
+
def chat(self, *user_prompt, **kwargs):
|
|
13
|
+
"""Databricks always reasoning"""
|
|
14
|
+
rs = super().chat(*user_prompt, **kwargs)
|
|
15
|
+
for r in rs:
|
|
16
|
+
assert len(r) == 2
|
|
17
|
+
assert r[0]['type'] == 'reasoning'
|
|
18
|
+
for s in r[0]['summary']:
|
|
19
|
+
assert s['type'] =='summary_text'
|
|
20
|
+
yield s['text']
|
|
21
|
+
assert r[1]['type'] == 'text'
|
|
22
|
+
yield r[1]['text']
|
|
23
|
+
|
davidkhala/ai/openai/native.py
CHANGED
|
@@ -7,10 +7,11 @@ from davidkhala.ai.openai import Client
|
|
|
7
7
|
|
|
8
8
|
class NativeClient(Client):
|
|
9
9
|
def __init__(self, api_key, base_url=None):
|
|
10
|
-
|
|
10
|
+
super().__init__(OpenAI(
|
|
11
11
|
api_key=api_key,
|
|
12
12
|
base_url=base_url
|
|
13
|
-
)
|
|
13
|
+
))
|
|
14
|
+
|
|
14
15
|
|
|
15
16
|
def chat(self, *user_prompt, web_search:Optional[Literal["low", "medium", "high"]]=None, **kwargs):
|
|
16
17
|
opts = {
|
davidkhala/ai/you.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from typing import AsyncIterator
|
|
2
|
+
|
|
3
|
+
from youdotcom import You, models
|
|
4
|
+
from youdotcom.models import Web
|
|
5
|
+
from youdotcom.types.typesafe_models import AgentType, get_text_tokens, Format
|
|
6
|
+
from youdotcom.utils import eventstreaming
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Client:
|
|
10
|
+
def __init__(self, api_key: str):
|
|
11
|
+
self.client = You(api_key_auth=api_key)
|
|
12
|
+
|
|
13
|
+
def chat(self, user_prompt: str, *, tools: list[models.Tool] = None) -> str:
|
|
14
|
+
res = self.client.agents.runs.create(
|
|
15
|
+
agent=AgentType.ADVANCED if tools else AgentType.EXPRESS,
|
|
16
|
+
input=user_prompt,
|
|
17
|
+
stream=False,
|
|
18
|
+
tools=tools,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
return "".join(get_text_tokens(res))
|
|
22
|
+
|
|
23
|
+
def scrape(self, *urls: str) -> list[str]:
|
|
24
|
+
"""
|
|
25
|
+
:return the content of the web pages as Markdown format (incl. metadata)
|
|
26
|
+
"""
|
|
27
|
+
res = self.client.contents.generate(
|
|
28
|
+
urls=list(urls),
|
|
29
|
+
format_=Format.MARKDOWN,
|
|
30
|
+
)
|
|
31
|
+
return [_.markdown for _ in res]
|
|
32
|
+
|
|
33
|
+
def search(self, query: str) -> list[Web]:
|
|
34
|
+
res = self.client.search.unified(
|
|
35
|
+
query=query
|
|
36
|
+
)
|
|
37
|
+
return res.results.web
|
|
38
|
+
|
|
39
|
+
async def async_chat(self, user_prompt: str) -> AsyncIterator[str]:
|
|
40
|
+
res: eventstreaming.EventStreamAsync[models.Data] = await self.client.agents.runs.create_async(
|
|
41
|
+
agent=AgentType.EXPRESS,
|
|
42
|
+
input=user_prompt,
|
|
43
|
+
stream=True,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
async for event in res:
|
|
47
|
+
if event.type == 'response.output_text.delta':
|
|
48
|
+
yield event.response.delta
|
|
49
|
+
|
|
50
|
+
def __enter__(self):
|
|
51
|
+
self.client.__enter__()
|
|
52
|
+
return self
|
|
53
|
+
|
|
54
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
55
|
+
self.client.close()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: davidkhala.ai
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: misc AI modules
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Provides-Extra: ali
|
|
@@ -28,12 +28,16 @@ Provides-Extra: langchain
|
|
|
28
28
|
Requires-Dist: langchain; extra == 'langchain'
|
|
29
29
|
Requires-Dist: langchain-openai; (python_version < '3.14') and extra == 'langchain'
|
|
30
30
|
Requires-Dist: langgraph; extra == 'langchain'
|
|
31
|
+
Provides-Extra: mistral
|
|
32
|
+
Requires-Dist: mistralai; extra == 'mistral'
|
|
31
33
|
Provides-Extra: openrouter
|
|
32
34
|
Requires-Dist: openrouter; extra == 'openrouter'
|
|
33
35
|
Provides-Extra: ragflow
|
|
34
36
|
Requires-Dist: ragflow-sdk; extra == 'ragflow'
|
|
35
37
|
Provides-Extra: telemetry
|
|
36
38
|
Requires-Dist: opik; (python_version < '3.14') and extra == 'telemetry'
|
|
39
|
+
Provides-Extra: you
|
|
40
|
+
Requires-Dist: youdotcom; extra == 'you'
|
|
37
41
|
Description-Content-Type: text/markdown
|
|
38
42
|
|
|
39
43
|
# davidkhala.ai
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
davidkhala/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
davidkhala/ai/model.py,sha256=1wcXC8X8oqerMatlcPbZmuxZ-nJWdJKmaDSDgiGlUGw,647
|
|
3
2
|
davidkhala/ai/opik.py,sha256=YU1XuweMUAzUkhpjxhltt-SBBDBkR3z-PCNo0DqzBRs,39
|
|
3
|
+
davidkhala/ai/you.py,sha256=fmMfJQZcG0e6sKfVQy2jOKZ-jkO-3H6GOGP2U19l4zQ,1759
|
|
4
4
|
davidkhala/ai/agent/README.md,sha256=kIPsx3gOjrpOw7w2qhNEALuCEQkuh4nYp6uBnijdvHE,178
|
|
5
5
|
davidkhala/ai/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
davidkhala/ai/agent/langgraph.py,sha256=jrc_Yvgo7eJjd3y5UJn0t1FzpnObDGYscwgsuVl2O_I,1052
|
|
@@ -15,7 +15,7 @@ davidkhala/ai/agent/dify/api/knowledge.py,sha256=5ePqvzjBHNtQ64Dzt39wBWedYVeQJc2
|
|
|
15
15
|
davidkhala/ai/agent/dify/ops/__init__.py,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
16
16
|
davidkhala/ai/agent/dify/ops/console/__init__.py,sha256=-a81jgCJ3s2B3i1GQ7ge1aZRfbvlALwGDHVu_GEET-A,237
|
|
17
17
|
davidkhala/ai/agent/dify/ops/console/knowledge.py,sha256=I1v0iE_b4VPc2Zsyt4ci_oX080Qbgn3oXObP4uVEphg,5788
|
|
18
|
-
davidkhala/ai/agent/dify/ops/console/plugin.py,sha256=
|
|
18
|
+
davidkhala/ai/agent/dify/ops/console/plugin.py,sha256=ZVi6KitSQTNvOd2mOAKYEPhjyOaGjtaaK-8VGFFooBY,2360
|
|
19
19
|
davidkhala/ai/agent/dify/ops/console/session.py,sha256=9IIdQqtTuYrc7QI9XpZxrCMb-K3m6QWH5FlsckSGCgg,991
|
|
20
20
|
davidkhala/ai/agent/dify/ops/db/__init__.py,sha256=HYfJEnoFAoJJck2xvTDYx8zpw9Qao7sHXOGvW0diPqw,517
|
|
21
21
|
davidkhala/ai/agent/dify/ops/db/app.py,sha256=IRiSiR0v387p4p3J7M9xEkJ7pfQyO5DL6chpx7Z2IzA,1319
|
|
@@ -26,11 +26,11 @@ davidkhala/ai/agent/dify/plugins/__init__.py,sha256=iTWvutlkN9bXgptesi05M447nTeF
|
|
|
26
26
|
davidkhala/ai/agent/dify/plugins/file.py,sha256=o-HjHSFwRTNIYs8IxqZUSnBbh-xr8f-xMUM3iU9wCCQ,390
|
|
27
27
|
davidkhala/ai/agent/dify/plugins/firecrawl.py,sha256=lB_f8W_bdg-7PeBKmF0-HdwYyakV_0D3nET5iT-Z1KM,460
|
|
28
28
|
davidkhala/ai/agent/dify/plugins/jina.py,sha256=dQ5iJxDLWtChXb1IjCtsHctgUtgjOiDfWOuR2u0aUIM,190
|
|
29
|
-
davidkhala/ai/agent/dify/plugins/popular.py,sha256=
|
|
29
|
+
davidkhala/ai/agent/dify/plugins/popular.py,sha256=XMuxqRcIko4gCQORg5HCcwCrbgLcaoRZxCYBIgtkrOo,812
|
|
30
30
|
davidkhala/ai/ali/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
31
|
davidkhala/ai/ali/agentbay.py,sha256=O5t71GGwtDgBE1zUXJDYe5djMVwSaNOwn5k8zg1xa18,1200
|
|
32
|
-
davidkhala/ai/ali/dashscope.py,sha256=
|
|
33
|
-
davidkhala/ai/api/__init__.py,sha256=
|
|
32
|
+
davidkhala/ai/ali/dashscope.py,sha256=3Dw-gxwO3iX6Z5_FdpkoNkwVmtXCLxklbOUcNCBzs_E,1945
|
|
33
|
+
davidkhala/ai/api/__init__.py,sha256=0uV1lFUiKYa7Xk-DEsYN22KkqR1a_aItqfdoZzfu1IA,1363
|
|
34
34
|
davidkhala/ai/api/openrouter.py,sha256=khccJr5cBnudFy6Jc2O3A1TNCuHH_5W6Q2tXrkwlUYE,2308
|
|
35
35
|
davidkhala/ai/api/siliconflow.py,sha256=JbnOSv8LJLtwYSNNB8_SMBMQzOgHDtQYZKA9A2BC4sY,2139
|
|
36
36
|
davidkhala/ai/google/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -39,10 +39,15 @@ davidkhala/ai/google/gemini.py,sha256=Xf4HDOOcK4-jEBERzuLnQNFsU61P2fFx4K0z-ijvNH
|
|
|
39
39
|
davidkhala/ai/huggingface/BAAI.py,sha256=LZ9kp5Gfql4UzuTn4osyekI6VV1H3RIfED2IolXFj5c,341
|
|
40
40
|
davidkhala/ai/huggingface/__init__.py,sha256=FJyU8eOfWQWKAvkIa5qwubF9ghsSQ8C0e6p6DKyomgs,521
|
|
41
41
|
davidkhala/ai/huggingface/inference.py,sha256=bYN0PtLF2CaIHzdTP4LaTALJhcawvuLnLR7rhMVqwDE,333
|
|
42
|
-
davidkhala/ai/
|
|
43
|
-
davidkhala/ai/
|
|
44
|
-
davidkhala/ai/
|
|
45
|
-
davidkhala/ai/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
davidkhala/ai/mistral/__init__.py,sha256=CFkTdRsVYZTIHpQRp-T9Dyx7K4RDYHzJokQkLDuJKdY,1090
|
|
43
|
+
davidkhala/ai/model/__init__.py,sha256=2gnScjS2X3vaYdXCmXCwhzXu8vgXWWn_GIsfsDFDbuU,964
|
|
44
|
+
davidkhala/ai/model/chat.py,sha256=2QEyM-9OFGRpcjsj6BTws3yiWixhzC_4x4HEh4ywhDM,409
|
|
45
|
+
davidkhala/ai/openai/__init__.py,sha256=LIb_2Ipk55aalYt88VkaHz97PzKSP7567rZxIjznb6Y,2044
|
|
46
|
+
davidkhala/ai/openai/azure.py,sha256=noO_tzoAhnyVVfFQ_kQhohqEG2XPlehyB-uT1leQLDk,1148
|
|
47
|
+
davidkhala/ai/openai/databricks.py,sha256=Z_ES3KlZuwMjMiGnlAxxrirLInQRVXj2KZs32MHXBbI,736
|
|
48
|
+
davidkhala/ai/openai/native.py,sha256=aQNjsls4kvoVGpytha9mMuC8KZ1OC5yKoO_WZzLBoyg,710
|
|
49
|
+
davidkhala/ai/openai/opik.py,sha256=ovodFNDoDO_ygX8_EmeqbZcu8PRTntzsNNQg4JoZKWo,257
|
|
50
|
+
davidkhala/ai/openrouter/__init__.py,sha256=hOe19DGhapvu4bh4y8URevC-PHb-0lb0R8kKEwj7LfQ,1065
|
|
51
|
+
davidkhala_ai-0.2.1.dist-info/METADATA,sha256=zwtKDpHzWKDlBoa_IYmPDE4OmuMrJ3-X6WJO4Qxnvec,1737
|
|
52
|
+
davidkhala_ai-0.2.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
53
|
+
davidkhala_ai-0.2.1.dist-info/RECORD,,
|
davidkhala/ai/model.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
from abc import ABC
|
|
2
|
-
from typing import Optional
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class AbstractClient(ABC):
|
|
6
|
-
api_key: str
|
|
7
|
-
base_url: str
|
|
8
|
-
model: Optional[str]
|
|
9
|
-
messages = []
|
|
10
|
-
|
|
11
|
-
def as_chat(self, model: str, sys_prompt: str = None):
|
|
12
|
-
self.model = model
|
|
13
|
-
if sys_prompt is not None:
|
|
14
|
-
self.messages = [{"role": "system", "content": sys_prompt}]
|
|
15
|
-
|
|
16
|
-
def as_embeddings(self, model: str):
|
|
17
|
-
self.model = model
|
|
18
|
-
|
|
19
|
-
def chat(self, *user_prompt, **kwargs):
|
|
20
|
-
...
|
|
21
|
-
|
|
22
|
-
def encode(self, *_input: str) -> list[list[float]]:
|
|
23
|
-
...
|
|
24
|
-
def connect(self):
|
|
25
|
-
...
|
|
26
|
-
|
|
27
|
-
def disconnect(self):
|
|
28
|
-
...
|
|
File without changes
|