langchain-zunno 0.1.0__tar.gz → 0.1.1__tar.gz
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.
- {langchain_zunno-0.1.0 → langchain_zunno-0.1.1}/PKG-INFO +1 -6
- {langchain_zunno-0.1.0 → langchain_zunno-0.1.1}/pyproject.toml +2 -3
- langchain_zunno-0.1.1/src/langchain_zunno/__init__.py +19 -0
- langchain_zunno-0.1.1/src/langchain_zunno/embeddings.py +115 -0
- langchain_zunno-0.1.1/src/langchain_zunno/llm.py +130 -0
- {langchain_zunno-0.1.0 → langchain_zunno-0.1.1/src}/langchain_zunno.egg-info/PKG-INFO +1 -6
- langchain_zunno-0.1.1/src/langchain_zunno.egg-info/SOURCES.txt +11 -0
- langchain_zunno-0.1.1/src/langchain_zunno.egg-info/top_level.txt +1 -0
- langchain_zunno-0.1.0/langchain_zunno.egg-info/SOURCES.txt +0 -9
- langchain_zunno-0.1.0/langchain_zunno.egg-info/top_level.txt +0 -1
- langchain_zunno-0.1.0/setup.py +0 -53
- {langchain_zunno-0.1.0 → langchain_zunno-0.1.1}/LICENSE +0 -0
- {langchain_zunno-0.1.0 → langchain_zunno-0.1.1}/README.md +0 -0
- {langchain_zunno-0.1.0 → langchain_zunno-0.1.1}/setup.cfg +0 -0
- {langchain_zunno-0.1.0 → langchain_zunno-0.1.1/src}/langchain_zunno.egg-info/dependency_links.txt +0 -0
- {langchain_zunno-0.1.0 → langchain_zunno-0.1.1/src}/langchain_zunno.egg-info/requires.txt +0 -0
@@ -1,9 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: langchain-zunno
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.1
|
4
4
|
Summary: LangChain integration for Zunno LLM and Embeddings
|
5
|
-
Home-page: https://github.com/zunno/langchain-zunno
|
6
|
-
Author: Amit Kumar
|
7
5
|
Author-email: Amit Kumar <amit@zunno.ai>
|
8
6
|
Maintainer-email: Amit Kumar <amit@zunno.ai>
|
9
7
|
License: MIT
|
@@ -38,10 +36,7 @@ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
38
36
|
Requires-Dist: black>=22.0.0; extra == "dev"
|
39
37
|
Requires-Dist: isort>=5.0.0; extra == "dev"
|
40
38
|
Requires-Dist: flake8>=4.0.0; extra == "dev"
|
41
|
-
Dynamic: author
|
42
|
-
Dynamic: home-page
|
43
39
|
Dynamic: license-file
|
44
|
-
Dynamic: requires-python
|
45
40
|
|
46
41
|
# LangChain Zunno Integration
|
47
42
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "langchain-zunno"
|
7
|
-
version = "0.1.
|
7
|
+
version = "0.1.1"
|
8
8
|
description = "LangChain integration for Zunno LLM and Embeddings"
|
9
9
|
readme = "README.md"
|
10
10
|
license = {text = "MIT"}
|
@@ -54,8 +54,7 @@ Repository = "https://github.com/zunno/langchain-zunno"
|
|
54
54
|
"Bug Tracker" = "https://github.com/zunno/langchain-zunno/issues"
|
55
55
|
|
56
56
|
[tool.setuptools.packages.find]
|
57
|
-
where = ["
|
58
|
-
include = ["langchain_zunno*"]
|
57
|
+
where = ["src"]
|
59
58
|
|
60
59
|
[tool.black]
|
61
60
|
line-length = 88
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"""
|
2
|
+
LangChain Zunno Integration
|
3
|
+
|
4
|
+
A LangChain integration for Zunno LLM and Embeddings.
|
5
|
+
"""
|
6
|
+
|
7
|
+
from .llm import ZunnoLLM, create_zunno_llm
|
8
|
+
from .embeddings import ZunnoLLMEmbeddings, create_zunno_embeddings
|
9
|
+
|
10
|
+
__version__ = "0.1.0"
|
11
|
+
__author__ = "Amit Kumar"
|
12
|
+
__email__ = "amit@zunno.ai"
|
13
|
+
|
14
|
+
__all__ = [
|
15
|
+
"ZunnoLLM",
|
16
|
+
"ZunnoLLMEmbeddings",
|
17
|
+
"create_zunno_llm",
|
18
|
+
"create_zunno_embeddings",
|
19
|
+
]
|
@@ -0,0 +1,115 @@
|
|
1
|
+
"""
|
2
|
+
LangChain Embeddings integration for Zunno.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from typing import List
|
6
|
+
from langchain.embeddings.base import Embeddings
|
7
|
+
import requests
|
8
|
+
|
9
|
+
|
10
|
+
class ZunnoLLMEmbeddings(Embeddings):
|
11
|
+
"""Zunno Embeddings wrapper for LangChain."""
|
12
|
+
|
13
|
+
model_name: str
|
14
|
+
base_url: str = "http://15.206.124.44/v1/text-embeddings"
|
15
|
+
timeout: int = 300
|
16
|
+
|
17
|
+
def __init__(self, model_name: str, base_url: str = None, timeout: int = 300):
|
18
|
+
super().__init__()
|
19
|
+
self.model_name = model_name
|
20
|
+
if base_url:
|
21
|
+
self.base_url = base_url
|
22
|
+
self.timeout = timeout
|
23
|
+
|
24
|
+
def embed_documents(self, texts: List[str]) -> List[List[float]]:
|
25
|
+
"""Embed a list of documents."""
|
26
|
+
embeddings = []
|
27
|
+
for text in texts:
|
28
|
+
embedding = self.embed_query(text)
|
29
|
+
embeddings.append(embedding)
|
30
|
+
return embeddings
|
31
|
+
|
32
|
+
def embed_query(self, text: str) -> List[float]:
|
33
|
+
"""Embed a single query."""
|
34
|
+
try:
|
35
|
+
payload = {
|
36
|
+
"model_name": self.model_name,
|
37
|
+
"text": text,
|
38
|
+
"options": {
|
39
|
+
"normalize": True
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
response = requests.post(
|
44
|
+
self.base_url,
|
45
|
+
json=payload,
|
46
|
+
timeout=self.timeout
|
47
|
+
)
|
48
|
+
|
49
|
+
if response.status_code != 200:
|
50
|
+
raise Exception(f"Zunno embeddings API error: {response.text}")
|
51
|
+
|
52
|
+
data = response.json()
|
53
|
+
embeddings = data.get("embeddings", [])
|
54
|
+
|
55
|
+
if not embeddings:
|
56
|
+
raise Exception("No embeddings returned from API")
|
57
|
+
|
58
|
+
return embeddings
|
59
|
+
|
60
|
+
except Exception as e:
|
61
|
+
raise Exception(f"Error getting text embeddings: {e}")
|
62
|
+
|
63
|
+
async def aembed_documents(self, texts: List[str]) -> List[List[float]]:
|
64
|
+
"""Async embed a list of documents."""
|
65
|
+
embeddings = []
|
66
|
+
for text in texts:
|
67
|
+
embedding = await self.aembed_query(text)
|
68
|
+
embeddings.append(embedding)
|
69
|
+
return embeddings
|
70
|
+
|
71
|
+
async def aembed_query(self, text: str) -> List[float]:
|
72
|
+
"""Async embed a single query."""
|
73
|
+
try:
|
74
|
+
import httpx
|
75
|
+
|
76
|
+
async with httpx.AsyncClient(timeout=self.timeout) as client:
|
77
|
+
payload = {
|
78
|
+
"model_name": self.model_name,
|
79
|
+
"text": text,
|
80
|
+
"options": {
|
81
|
+
"normalize": True
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
response = await client.post(
|
86
|
+
self.base_url,
|
87
|
+
json=payload
|
88
|
+
)
|
89
|
+
|
90
|
+
if response.status_code != 200:
|
91
|
+
raise Exception(f"Zunno embeddings API error: {response.text}")
|
92
|
+
|
93
|
+
data = response.json()
|
94
|
+
embeddings = data.get("embeddings", [])
|
95
|
+
|
96
|
+
if not embeddings:
|
97
|
+
raise Exception("No embeddings returned from API")
|
98
|
+
|
99
|
+
return embeddings
|
100
|
+
|
101
|
+
except Exception as e:
|
102
|
+
raise Exception(f"Error getting text embeddings: {e}")
|
103
|
+
|
104
|
+
|
105
|
+
def create_zunno_embeddings(
|
106
|
+
model_name: str,
|
107
|
+
base_url: str = "http://15.206.124.44/v1/text-embeddings",
|
108
|
+
timeout: int = 300
|
109
|
+
) -> ZunnoLLMEmbeddings:
|
110
|
+
"""Create a Zunno Embeddings instance."""
|
111
|
+
return ZunnoLLMEmbeddings(
|
112
|
+
model_name=model_name,
|
113
|
+
base_url=base_url,
|
114
|
+
timeout=timeout
|
115
|
+
)
|
@@ -0,0 +1,130 @@
|
|
1
|
+
"""
|
2
|
+
LangChain LLM integration for Zunno.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from typing import Any, List, Optional, Dict
|
6
|
+
from langchain.llms.base import LLM
|
7
|
+
from langchain.callbacks.manager import CallbackManagerForLLMRun
|
8
|
+
import requests
|
9
|
+
|
10
|
+
|
11
|
+
class ZunnoLLM(LLM):
|
12
|
+
"""Zunno LLM wrapper for LangChain."""
|
13
|
+
|
14
|
+
model_name: str
|
15
|
+
base_url: str = "http://15.206.124.44/v1/prompt-response"
|
16
|
+
temperature: float = 0.7
|
17
|
+
max_tokens: Optional[int] = None
|
18
|
+
timeout: int = 300
|
19
|
+
|
20
|
+
@property
|
21
|
+
def _llm_type(self) -> str:
|
22
|
+
"""Return type of LLM."""
|
23
|
+
return "zunno"
|
24
|
+
|
25
|
+
@property
|
26
|
+
def _identifying_params(self) -> Dict[str, Any]:
|
27
|
+
"""Get the identifying parameters."""
|
28
|
+
return {
|
29
|
+
"model_name": self.model_name,
|
30
|
+
"temperature": self.temperature,
|
31
|
+
"max_tokens": self.max_tokens,
|
32
|
+
"base_url": self.base_url,
|
33
|
+
}
|
34
|
+
|
35
|
+
def _call(
|
36
|
+
self,
|
37
|
+
prompt: str,
|
38
|
+
stop: Optional[List[str]] = None,
|
39
|
+
run_manager: Optional[CallbackManagerForLLMRun] = None,
|
40
|
+
**kwargs: Any,
|
41
|
+
) -> str:
|
42
|
+
"""Call the Zunno API."""
|
43
|
+
try:
|
44
|
+
payload = {
|
45
|
+
"model_name": self.model_name,
|
46
|
+
"prompt": prompt,
|
47
|
+
"stream": False,
|
48
|
+
"options": {
|
49
|
+
"temperature": self.temperature,
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
if self.max_tokens:
|
54
|
+
payload["options"]["num_predict"] = self.max_tokens
|
55
|
+
|
56
|
+
if stop:
|
57
|
+
payload["options"]["stop"] = stop
|
58
|
+
|
59
|
+
response = requests.post(
|
60
|
+
self.base_url,
|
61
|
+
json=payload,
|
62
|
+
timeout=self.timeout
|
63
|
+
)
|
64
|
+
|
65
|
+
if response.status_code != 200:
|
66
|
+
raise Exception(f"Zunno API error: {response.text}")
|
67
|
+
|
68
|
+
data = response.json()
|
69
|
+
return data.get("response", "")
|
70
|
+
|
71
|
+
except Exception as e:
|
72
|
+
raise Exception(f"Error calling Zunno LLM: {e}")
|
73
|
+
|
74
|
+
async def _acall(
|
75
|
+
self,
|
76
|
+
prompt: str,
|
77
|
+
stop: Optional[List[str]] = None,
|
78
|
+
run_manager: Optional[CallbackManagerForLLMRun] = None,
|
79
|
+
**kwargs: Any,
|
80
|
+
) -> str:
|
81
|
+
"""Async call to the Zunno API."""
|
82
|
+
try:
|
83
|
+
import httpx
|
84
|
+
|
85
|
+
async with httpx.AsyncClient(timeout=self.timeout) as client:
|
86
|
+
payload = {
|
87
|
+
"model_name": self.model_name,
|
88
|
+
"prompt": prompt,
|
89
|
+
"stream": False,
|
90
|
+
"options": {
|
91
|
+
"temperature": self.temperature,
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
if self.max_tokens:
|
96
|
+
payload["options"]["num_predict"] = self.max_tokens
|
97
|
+
|
98
|
+
if stop:
|
99
|
+
payload["options"]["stop"] = stop
|
100
|
+
|
101
|
+
response = await client.post(
|
102
|
+
self.base_url,
|
103
|
+
json=payload
|
104
|
+
)
|
105
|
+
|
106
|
+
if response.status_code != 200:
|
107
|
+
raise Exception(f"Zunno API error: {response.text}")
|
108
|
+
|
109
|
+
data = response.json()
|
110
|
+
return data.get("response", "")
|
111
|
+
|
112
|
+
except Exception as e:
|
113
|
+
raise Exception(f"Error calling Zunno LLM: {e}")
|
114
|
+
|
115
|
+
|
116
|
+
def create_zunno_llm(
|
117
|
+
model_name: str,
|
118
|
+
temperature: float = 0.7,
|
119
|
+
max_tokens: Optional[int] = None,
|
120
|
+
base_url: str = "http://15.206.124.44/v1/prompt-response",
|
121
|
+
timeout: int = 300
|
122
|
+
) -> ZunnoLLM:
|
123
|
+
"""Create a Zunno LLM instance."""
|
124
|
+
return ZunnoLLM(
|
125
|
+
model_name=model_name,
|
126
|
+
temperature=temperature,
|
127
|
+
max_tokens=max_tokens,
|
128
|
+
base_url=base_url,
|
129
|
+
timeout=timeout
|
130
|
+
)
|
@@ -1,9 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: langchain-zunno
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.1
|
4
4
|
Summary: LangChain integration for Zunno LLM and Embeddings
|
5
|
-
Home-page: https://github.com/zunno/langchain-zunno
|
6
|
-
Author: Amit Kumar
|
7
5
|
Author-email: Amit Kumar <amit@zunno.ai>
|
8
6
|
Maintainer-email: Amit Kumar <amit@zunno.ai>
|
9
7
|
License: MIT
|
@@ -38,10 +36,7 @@ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
38
36
|
Requires-Dist: black>=22.0.0; extra == "dev"
|
39
37
|
Requires-Dist: isort>=5.0.0; extra == "dev"
|
40
38
|
Requires-Dist: flake8>=4.0.0; extra == "dev"
|
41
|
-
Dynamic: author
|
42
|
-
Dynamic: home-page
|
43
39
|
Dynamic: license-file
|
44
|
-
Dynamic: requires-python
|
45
40
|
|
46
41
|
# LangChain Zunno Integration
|
47
42
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
LICENSE
|
2
|
+
README.md
|
3
|
+
pyproject.toml
|
4
|
+
src/langchain_zunno/__init__.py
|
5
|
+
src/langchain_zunno/embeddings.py
|
6
|
+
src/langchain_zunno/llm.py
|
7
|
+
src/langchain_zunno.egg-info/PKG-INFO
|
8
|
+
src/langchain_zunno.egg-info/SOURCES.txt
|
9
|
+
src/langchain_zunno.egg-info/dependency_links.txt
|
10
|
+
src/langchain_zunno.egg-info/requires.txt
|
11
|
+
src/langchain_zunno.egg-info/top_level.txt
|
@@ -0,0 +1 @@
|
|
1
|
+
langchain_zunno
|
@@ -1 +0,0 @@
|
|
1
|
-
|
langchain_zunno-0.1.0/setup.py
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
from setuptools import setup, find_packages
|
2
|
-
|
3
|
-
with open("README.md", "r", encoding="utf-8") as fh:
|
4
|
-
long_description = fh.read()
|
5
|
-
|
6
|
-
setup(
|
7
|
-
name="langchain-zunno",
|
8
|
-
version="0.1.0",
|
9
|
-
author="Amit Kumar",
|
10
|
-
author_email="amit@zunno.ai",
|
11
|
-
description="LangChain integration for Zunno LLM and Embeddings",
|
12
|
-
long_description=long_description,
|
13
|
-
long_description_content_type="text/markdown",
|
14
|
-
url="https://github.com/zunno/langchain-zunno",
|
15
|
-
packages=find_packages(),
|
16
|
-
classifiers=[
|
17
|
-
"Development Status :: 3 - Alpha",
|
18
|
-
"Intended Audience :: Developers",
|
19
|
-
"License :: OSI Approved :: MIT License",
|
20
|
-
"Operating System :: OS Independent",
|
21
|
-
"Programming Language :: Python :: 3",
|
22
|
-
"Programming Language :: Python :: 3.8",
|
23
|
-
"Programming Language :: Python :: 3.9",
|
24
|
-
"Programming Language :: Python :: 3.10",
|
25
|
-
"Programming Language :: Python :: 3.11",
|
26
|
-
"Programming Language :: Python :: 3.12",
|
27
|
-
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
28
|
-
"Topic :: Software Development :: Libraries :: Python Modules",
|
29
|
-
],
|
30
|
-
python_requires=">=3.8",
|
31
|
-
install_requires=[
|
32
|
-
"langchain>=0.1.0",
|
33
|
-
"langchain-core>=0.1.0",
|
34
|
-
"requests>=2.25.0",
|
35
|
-
"httpx>=0.24.0",
|
36
|
-
"pydantic>=2.0.0",
|
37
|
-
],
|
38
|
-
extras_require={
|
39
|
-
"dev": [
|
40
|
-
"pytest>=7.0.0",
|
41
|
-
"pytest-asyncio>=0.21.0",
|
42
|
-
"black>=22.0.0",
|
43
|
-
"isort>=5.0.0",
|
44
|
-
"flake8>=4.0.0",
|
45
|
-
],
|
46
|
-
},
|
47
|
-
keywords="langchain, llm, embeddings, zunno, ai, machine-learning",
|
48
|
-
project_urls={
|
49
|
-
"Bug Reports": "https://github.com/zunno/langchain-zunno/issues",
|
50
|
-
"Source": "https://github.com/zunno/langchain-zunno",
|
51
|
-
"Documentation": "https://github.com/zunno/langchain-zunno#readme",
|
52
|
-
},
|
53
|
-
)
|
File without changes
|
File without changes
|
File without changes
|
{langchain_zunno-0.1.0 → langchain_zunno-0.1.1/src}/langchain_zunno.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|