pinetext 0.1.0__py3-none-any.whl → 0.1.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.

Potentially problematic release.


This version of pinetext might be problematic. Click here for more details.

pinetext/client.py CHANGED
@@ -1,3 +1,8 @@
1
+ from pathlib import Path
2
+
3
+ from pinecone import Pinecone
4
+ from pinecone_plugins.assistant.models.chat import Message
5
+
1
6
  from pinetext.settings import Settings
2
7
 
3
8
 
@@ -8,5 +13,40 @@ class PineText:
8
13
  def __init__(self):
9
14
  pass
10
15
 
16
+ def get_or_create_assistant(self, name: str):
17
+ try:
18
+ return self.pinecone.assistant.describe_assistant(assistant_name=name)
19
+ except Exception:
20
+ return self.pinecone.assistant.create_assistant(assistant_name=name)
21
+
22
+ def upload_files(self, path: str):
23
+ folder = Path(path)
24
+ if folder.is_dir():
25
+ uploaded = [x.name for x in self.assistant.list_files()]
26
+ for x in sorted(folder.iterdir()):
27
+ if x.name not in uploaded:
28
+ self.assistant.upload_file(
29
+ file_path=str(x.resolve()),
30
+ metadata={
31
+ "filename": x.name,
32
+ "extension": x.suffix.lower().lstrip("."),
33
+ },
34
+ timeout=None,
35
+ )
36
+
37
+ def chat(self, text: str, model: str):
38
+ msg = Message(role="user", content=text)
39
+ resp = self.assistant.chat(messages=[msg], model=model)
40
+ return resp.message.content
41
+
11
42
  def run(self):
12
- print("OK")
43
+ self.pinecone = Pinecone(api_key=settings.pinecone.api_key)
44
+ self.assistant = self.get_or_create_assistant(settings.pinecone.assistant)
45
+ self.upload_files(settings.pinecone.data_dir)
46
+
47
+ while True:
48
+ text = input("> ").strip()
49
+ if text.lower() in ("exit", "quit"):
50
+ break
51
+ res = self.chat(text, settings.pinecone.model)
52
+ print(res)
pinetext/settings.py CHANGED
@@ -1,10 +1,19 @@
1
+ from pydantic import BaseModel
1
2
  from pydantic_settings import BaseSettings, SettingsConfigDict
2
3
 
3
4
 
5
+ class Pinecone(BaseModel):
6
+ api_key: str | None = None
7
+ assistant: str | None = "test-assistant"
8
+ data_dir: str | None = "data"
9
+ model: str | None = "o4-mini"
10
+
11
+
4
12
  class Settings(BaseSettings):
5
- pinecone_key: str | None = None
13
+ pinecone: Pinecone = Pinecone()
6
14
  model_config = SettingsConfigDict(
7
15
  env_file=".env",
8
16
  env_file_encoding="utf-8",
9
17
  env_nested_delimiter="__",
18
+ env_prefix="PINETEXT_",
10
19
  )
@@ -0,0 +1,86 @@
1
+ Metadata-Version: 2.4
2
+ Name: pinetext
3
+ Version: 0.1.1
4
+ Summary: PineText
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.13
7
+ Requires-Dist: pinecone-plugin-assistant>=1.7.0
8
+ Requires-Dist: pinecone>=7.3.0
9
+ Requires-Dist: pydantic-settings>=2.10.1
10
+ Requires-Dist: typer>=0.16.0
11
+ Description-Content-Type: text/markdown
12
+
13
+ ## PineText
14
+
15
+ [![test](https://github.com/ezhuk/pinetext/actions/workflows/test.yml/badge.svg)](https://github.com/ezhuk/pinetext/actions/workflows/test.yml)
16
+ [![codecov](https://codecov.io/github/ezhuk/pinetext/graph/badge.svg?token=0YJASFE5OM)](https://codecov.io/github/ezhuk/pinetext)
17
+ [![PyPI - Version](https://img.shields.io/pypi/v/pinetext.svg)](https://pypi.org/p/pinetext)
18
+
19
+ A lightweight assistant built using [Pinecone](https://docs.pinecone.io/guides/assistant/overview) that helps create RAG-based chat applications for reasoning over documents, retrieving relevant context, and providing grounded answers.
20
+
21
+ ## Getting Started
22
+
23
+ Use [uv](https://github.com/astral-sh/uv) to add and manage PineText as a dependency in your project, or install it directly via `uv pip install` or `pip install`. See the [Installation](https://github.com/ezhuk/modbus-mcp/blob/main/docs/modbus-mcp/installation.mdx) section of the documentation for full installation instructions and more details.
24
+
25
+ ```bash
26
+ uv add pinetext
27
+ ```
28
+
29
+ It can be embedded in and run directly from your application.
30
+
31
+ ```python
32
+ # app.py
33
+ from pinetext import PineText
34
+
35
+ def main():
36
+ pt = PineText()
37
+ pt.run()
38
+ ```
39
+
40
+ It can also be launched from the command line using the provided `CLI` without modifying the source code.
41
+
42
+ ```
43
+ pinetext
44
+ ```
45
+
46
+ Or in an ephemeral, isolated environment using `uvx`. Check out the [Using tools](https://docs.astral.sh/uv/guides/tools/) guide for more details.
47
+
48
+ ```bash
49
+ uvx pinetext
50
+ ```
51
+
52
+ ## Configuration
53
+
54
+ Place documents in the `data` folder and make sure to set `PINECONE_API_KEY` and the assistant name before starting PineText.
55
+
56
+ ```bash
57
+ export PINETEXT_PINECONE__API_KEY=your-api-key
58
+ export PINETEXT_PINECONE__ASSISTANT=assistant-name
59
+ export PINETEXT_PINECONE__DATA_DIR=data
60
+ export PINETEXT_PINECONE__MODEL=o4-mini
61
+ ```
62
+
63
+ These settings can also be specified in a `.env` file in the working directory.
64
+
65
+ ```text
66
+ pinetext_pinecone__api_key=your-api-key
67
+ pinetext_pinecone__assistant=assistant-name
68
+ pinetext_pinecone__data_dir=data
69
+ pinetext_pinecone__model=o4-mini
70
+ ```
71
+
72
+ ## Docker
73
+
74
+ The PineText CLI can be deployed as a Docker container as follows:
75
+
76
+ ```bash
77
+ docker run -it \
78
+ --name pinetext \
79
+ --env-file .env \
80
+ -v $(pwd)/data:/app/data
81
+ ghcr.io/ezhuk/pinetext:latest
82
+ ```
83
+
84
+ ## License
85
+
86
+ The server is licensed under the [MIT License](https://github.com/ezhuk/pinetext?tab=MIT-1-ov-file).
@@ -0,0 +1,9 @@
1
+ pinetext/__init__.py,sha256=VQZQcYgadJGizofgf7Qe6vPlC8zIiv_kTiQC4Ftzfac,136
2
+ pinetext/cli.py,sha256=ensHQ7RQvsZG7PIvSEVsRLJEvgPOf5ZrVDRUi2ZsJJM,189
3
+ pinetext/client.py,sha256=YSVTNMMverEVqjLliqy0TL8Y-Xo4fHDTgqDq3da0yXk,1715
4
+ pinetext/settings.py,sha256=nkHmg2zilfJA7RDELJB6vaqfuisVygBv5FoMz9Zg0ew,507
5
+ pinetext-0.1.1.dist-info/METADATA,sha256=kxB34o0p3XwyF7iM_fLzkVAwiu-3WH3ru5e0pYYKYNc,2686
6
+ pinetext-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ pinetext-0.1.1.dist-info/entry_points.txt,sha256=kV_mlYLNZRAerrjTMaKHwpQoPAejaJ7Crjvpck5D3KQ,46
8
+ pinetext-0.1.1.dist-info/licenses/LICENSE,sha256=uSsFh4jumQQchhdeV61a1YhWRAp1GouNAoEduU_93kU,1068
9
+ pinetext-0.1.1.dist-info/RECORD,,
@@ -1,15 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pinetext
3
- Version: 0.1.0
4
- Summary: PineText
5
- License-File: LICENSE
6
- Requires-Python: >=3.13
7
- Requires-Dist: pinecone>=7.3.0
8
- Requires-Dist: pydantic-settings>=2.10.1
9
- Requires-Dist: typer>=0.16.0
10
- Description-Content-Type: text/markdown
11
-
12
- ## PineText
13
-
14
- [![test](https://github.com/ezhuk/pinetext/actions/workflows/test.yml/badge.svg)](https://github.com/ezhuk/pinetext/actions/workflows/test.yml)
15
- [![codecov](https://codecov.io/github/ezhuk/pinetext/graph/badge.svg?token=0YJASFE5OM)](https://codecov.io/github/ezhuk/pinetext)
@@ -1,9 +0,0 @@
1
- pinetext/__init__.py,sha256=VQZQcYgadJGizofgf7Qe6vPlC8zIiv_kTiQC4Ftzfac,136
2
- pinetext/cli.py,sha256=ensHQ7RQvsZG7PIvSEVsRLJEvgPOf5ZrVDRUi2ZsJJM,189
3
- pinetext/client.py,sha256=AyKifEdono9_J3hzaqMI55tjMprEZAB-yieTTnISJU4,158
4
- pinetext/settings.py,sha256=v1Twv_5MtgOfkYHamnp9ZKa8Jv2hxALJLweAzLBWkqw,271
5
- pinetext-0.1.0.dist-info/METADATA,sha256=mBsLrlHrtSsfv-eh3Xutdjs5gahimHcwkzUK2rSgVnc,545
6
- pinetext-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- pinetext-0.1.0.dist-info/entry_points.txt,sha256=kV_mlYLNZRAerrjTMaKHwpQoPAejaJ7Crjvpck5D3KQ,46
8
- pinetext-0.1.0.dist-info/licenses/LICENSE,sha256=uSsFh4jumQQchhdeV61a1YhWRAp1GouNAoEduU_93kU,1068
9
- pinetext-0.1.0.dist-info/RECORD,,