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