euriai 0.3.11__py3-none-any.whl → 0.3.13__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.
- euriai/llamaindex/euri_chat.py +47 -10
- {euriai-0.3.11.dist-info → euriai-0.3.13.dist-info}/METADATA +1 -1
- {euriai-0.3.11.dist-info → euriai-0.3.13.dist-info}/RECORD +6 -6
- {euriai-0.3.11.dist-info → euriai-0.3.13.dist-info}/WHEEL +0 -0
- {euriai-0.3.11.dist-info → euriai-0.3.13.dist-info}/entry_points.txt +0 -0
- {euriai-0.3.11.dist-info → euriai-0.3.13.dist-info}/top_level.txt +0 -0
euriai/llamaindex/euri_chat.py
CHANGED
@@ -1,32 +1,69 @@
|
|
1
1
|
import requests
|
2
|
-
from llama_index.core.llms import LLM
|
3
|
-
from llama_index.core.llms.types import ChatMessage, CompletionResponse
|
4
2
|
from typing import List
|
3
|
+
from llama_index.core.llms import LLM
|
4
|
+
from llama_index.core.base.llms.types import ChatMessage, CompletionResponse, CompletionResponseGen
|
5
|
+
|
5
6
|
|
6
7
|
class EuriaiLlamaIndexLLM(LLM):
|
7
|
-
def __init__(
|
8
|
+
def __init__(
|
9
|
+
self,
|
10
|
+
api_key: str,
|
11
|
+
model: str = "gpt-4.1-nano",
|
12
|
+
temperature: float = 0.7,
|
13
|
+
max_tokens: int = 1000,
|
14
|
+
):
|
8
15
|
self.api_key = api_key
|
9
16
|
self.model = model
|
10
17
|
self.temperature = temperature
|
11
18
|
self.max_tokens = max_tokens
|
12
19
|
self.url = "https://api.euron.one/api/v1/chat/completions"
|
13
20
|
|
14
|
-
|
15
|
-
|
21
|
+
@property
|
22
|
+
def metadata(self):
|
23
|
+
return {
|
24
|
+
"context_window": 8000,
|
25
|
+
"num_output": self.max_tokens,
|
26
|
+
"is_chat_model": True,
|
27
|
+
"model_name": self.model,
|
28
|
+
}
|
16
29
|
|
17
30
|
def chat(self, messages: List[ChatMessage], **kwargs) -> CompletionResponse:
|
31
|
+
headers = {
|
32
|
+
"Content-Type": "application/json",
|
33
|
+
"Authorization": f"Bearer {self.api_key}",
|
34
|
+
}
|
18
35
|
payload = {
|
19
36
|
"messages": [{"role": m.role, "content": m.content} for m in messages],
|
20
37
|
"model": self.model,
|
21
38
|
"temperature": self.temperature,
|
22
|
-
"max_tokens": self.max_tokens
|
23
|
-
}
|
24
|
-
headers = {
|
25
|
-
"Content-Type": "application/json",
|
26
|
-
"Authorization": f"Bearer {self.api_key}"
|
39
|
+
"max_tokens": self.max_tokens,
|
27
40
|
}
|
41
|
+
|
28
42
|
response = requests.post(self.url, headers=headers, json=payload)
|
29
43
|
response.raise_for_status()
|
30
44
|
result = response.json()
|
31
45
|
content = result["choices"][0]["message"]["content"]
|
46
|
+
|
32
47
|
return CompletionResponse(text=content)
|
48
|
+
|
49
|
+
def complete(self, prompt: str, **kwargs) -> CompletionResponse:
|
50
|
+
return self.chat([ChatMessage(role="user", content=prompt)])
|
51
|
+
|
52
|
+
# Async versions (not supported, so raise or return NotImplementedError)
|
53
|
+
async def achat(self, messages: List[ChatMessage], **kwargs) -> CompletionResponse:
|
54
|
+
raise NotImplementedError("Async chat not implemented for Euriai.")
|
55
|
+
|
56
|
+
async def acomplete(self, prompt: str, **kwargs) -> CompletionResponse:
|
57
|
+
raise NotImplementedError("Async complete not implemented for Euriai.")
|
58
|
+
|
59
|
+
def stream_chat(self, messages: List[ChatMessage], **kwargs) -> CompletionResponseGen:
|
60
|
+
raise NotImplementedError("Streaming not supported in EuriaiLlamaIndexLLM.")
|
61
|
+
|
62
|
+
def stream_complete(self, prompt: str, **kwargs) -> CompletionResponseGen:
|
63
|
+
raise NotImplementedError("Streaming not supported in EuriaiLlamaIndexLLM.")
|
64
|
+
|
65
|
+
async def astream_chat(self, messages: List[ChatMessage], **kwargs) -> CompletionResponseGen:
|
66
|
+
raise NotImplementedError("Async streaming not supported in EuriaiLlamaIndexLLM.")
|
67
|
+
|
68
|
+
async def astream_complete(self, prompt: str, **kwargs) -> CompletionResponseGen:
|
69
|
+
raise NotImplementedError("Async streaming not supported in EuriaiLlamaIndexLLM.")
|
@@ -5,10 +5,10 @@ euriai/embedding.py,sha256=z-LLKU68tCrPi9QMs1tlKwyr7WJcjceCTkNQIFMG6vA,1276
|
|
5
5
|
euriai/langchain_embed.py,sha256=OXWWxiKJ4g24TFgnWPOCZvhK7G8xtSf0ppQ2zwHkIPM,584
|
6
6
|
euriai/langchain_llm.py,sha256=D5YvYwV7q9X2_vdoaQiPs7tNiUmjkGz-9Q-7M61hhkg,986
|
7
7
|
euriai/llamaindex/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
euriai/llamaindex/euri_chat.py,sha256=
|
8
|
+
euriai/llamaindex/euri_chat.py,sha256=_n3LpslD-QsDKtB3oCMjatgwqmTv7TtKJSvGzCsS0LM,2816
|
9
9
|
euriai/llamaindex/euri_embed.py,sha256=RO62uzT9rStp9_Ow2cYa_ZrGabkPFX89ZL3Mgb13X08,1063
|
10
|
-
euriai-0.3.
|
11
|
-
euriai-0.3.
|
12
|
-
euriai-0.3.
|
13
|
-
euriai-0.3.
|
14
|
-
euriai-0.3.
|
10
|
+
euriai-0.3.13.dist-info/METADATA,sha256=u3jmtY4iHdw1P9BVJzxsV-y6OU0EFqgbcJiIkBQbGeU,3257
|
11
|
+
euriai-0.3.13.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
12
|
+
euriai-0.3.13.dist-info/entry_points.txt,sha256=9OkET8KIGcsjQn8UlnpPKRT75s2KW34jq1__1SXtpMA,43
|
13
|
+
euriai-0.3.13.dist-info/top_level.txt,sha256=TG1htJ8cuD62MXn-NJ7DVF21QHY16w6M_QgfF_Er_EQ,7
|
14
|
+
euriai-0.3.13.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|