pinetext 0.1.0__py3-none-any.whl → 0.1.2__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,11 @@
1
+ import wandb
2
+ import weave
3
+
4
+ from pathlib import Path
5
+
6
+ from pinecone import Pinecone
7
+ from pinecone_plugins.assistant.models.chat import Message
8
+
1
9
  from pinetext.settings import Settings
2
10
 
3
11
 
@@ -8,5 +16,44 @@ class PineText:
8
16
  def __init__(self):
9
17
  pass
10
18
 
19
+ def get_or_create_assistant(self, name: str):
20
+ try:
21
+ return self.pinecone.assistant.describe_assistant(assistant_name=name)
22
+ except Exception:
23
+ return self.pinecone.assistant.create_assistant(assistant_name=name)
24
+
25
+ def upload_files(self, path: str):
26
+ folder = Path(path)
27
+ if folder.is_dir():
28
+ uploaded = [x.name for x in self.assistant.list_files()]
29
+ for x in sorted(folder.iterdir()):
30
+ if x.name not in uploaded:
31
+ self.assistant.upload_file(
32
+ file_path=str(x.resolve()),
33
+ metadata={
34
+ "filename": x.name,
35
+ "extension": x.suffix.lower().lstrip("."),
36
+ },
37
+ timeout=None,
38
+ )
39
+
40
+ @weave.op()
41
+ def chat(self, text: str, model: str):
42
+ msg = Message(role="user", content=text)
43
+ resp = self.assistant.chat(messages=[msg], model=model)
44
+ return resp.message.content
45
+
11
46
  def run(self):
12
- print("OK")
47
+ if settings.wandb.api_key:
48
+ wandb.login(key=settings.wandb.api_key)
49
+ weave.init(settings.wandb.project)
50
+ self.pinecone = Pinecone(api_key=settings.pinecone.api_key)
51
+ self.assistant = self.get_or_create_assistant(settings.pinecone.assistant)
52
+ self.upload_files(settings.pinecone.data_dir)
53
+
54
+ while True:
55
+ text = input("> ").strip()
56
+ if text.lower() in ("exit", "quit"):
57
+ break
58
+ res = self.chat(text, settings.pinecone.model)
59
+ print(res)
pinetext/settings.py CHANGED
@@ -1,10 +1,25 @@
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
+
12
+ class WandB(BaseModel):
13
+ api_key: str | None = None
14
+ project: str | None = "pinetext"
15
+
16
+
4
17
  class Settings(BaseSettings):
5
- pinecone_key: str | None = None
18
+ pinecone: Pinecone = Pinecone()
19
+ wandb: WandB = WandB()
6
20
  model_config = SettingsConfigDict(
7
21
  env_file=".env",
8
22
  env_file_encoding="utf-8",
9
23
  env_nested_delimiter="__",
24
+ env_prefix="PINETEXT_",
10
25
  )
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.4
2
+ Name: pinetext
3
+ Version: 0.1.2
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
+ Requires-Dist: wandb>=0.21.1
12
+ Requires-Dist: weave>=0.51.59
13
+ Description-Content-Type: text/markdown
14
+
15
+ ## PineText
16
+
17
+ [![test](https://github.com/ezhuk/pinetext/actions/workflows/test.yml/badge.svg)](https://github.com/ezhuk/pinetext/actions/workflows/test.yml)
18
+ [![codecov](https://codecov.io/github/ezhuk/pinetext/graph/badge.svg?token=0YJASFE5OM)](https://codecov.io/github/ezhuk/pinetext)
19
+ [![PyPI - Version](https://img.shields.io/pypi/v/pinetext.svg)](https://pypi.org/p/pinetext)
20
+
21
+ 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.
22
+
23
+ ## Getting Started
24
+
25
+ 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/pinetext/blob/main/docs/pinetext/installation.mdx) section of the documentation for full installation instructions and more details.
26
+
27
+ ```bash
28
+ uv add pinetext
29
+ ```
30
+
31
+ It can be embedded in and run directly from your application.
32
+
33
+ ```python
34
+ # app.py
35
+ from pinetext import PineText
36
+
37
+ def main():
38
+ pt = PineText()
39
+ pt.run()
40
+ ```
41
+
42
+ It can also be launched from the command line using the provided `CLI` without modifying the source code.
43
+
44
+ ```
45
+ pinetext
46
+ ```
47
+
48
+ Or in an ephemeral, isolated environment using `uvx`. Check out the [Using tools](https://docs.astral.sh/uv/guides/tools/) guide for more details.
49
+
50
+ ```bash
51
+ uvx pinetext
52
+ ```
53
+
54
+ ## Configuration
55
+
56
+ Place documents in the `data` folder and make sure to set `PINECONE_API_KEY` and the assistant name before starting PineText.
57
+
58
+ ```bash
59
+ export PINETEXT_PINECONE__API_KEY=your-api-key
60
+ export PINETEXT_PINECONE__ASSISTANT=assistant-name
61
+ export PINETEXT_PINECONE__DATA_DIR=data
62
+ export PINETEXT_PINECONE__MODEL=o4-mini
63
+ ```
64
+
65
+ These settings can also be specified in a `.env` file in the working directory.
66
+
67
+ ```text
68
+ pinetext_pinecone__api_key=your-api-key
69
+ pinetext_pinecone__assistant=assistant-name
70
+ pinetext_pinecone__data_dir=data
71
+ pinetext_pinecone__model=o4-mini
72
+ ```
73
+
74
+ ## Docker
75
+
76
+ The PineText CLI can be deployed as a Docker container as follows:
77
+
78
+ ```bash
79
+ docker run -it \
80
+ --name pinetext \
81
+ --env-file .env \
82
+ -v $(pwd)/data:/app/data
83
+ ghcr.io/ezhuk/pinetext:latest
84
+ ```
85
+
86
+ Or using Docker Compose:
87
+
88
+ ```bash
89
+ docker compose up
90
+ ```
91
+
92
+ ## License
93
+
94
+ 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=hYKhaefZ4L6PUDvPxwicjnztlAkgVLIZxM8sr5he_18,1892
4
+ pinetext/settings.py,sha256=B4-gtpFlaz-M1Zf5RXC5MK2gh8faLLHUxtO7wWPCgsI,628
5
+ pinetext-0.1.2.dist-info/METADATA,sha256=KxtSrVYTVYEQQP6F9DuGR4d_9pMh5kTqM_L3iduXads,2798
6
+ pinetext-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ pinetext-0.1.2.dist-info/entry_points.txt,sha256=kV_mlYLNZRAerrjTMaKHwpQoPAejaJ7Crjvpck5D3KQ,46
8
+ pinetext-0.1.2.dist-info/licenses/LICENSE,sha256=uSsFh4jumQQchhdeV61a1YhWRAp1GouNAoEduU_93kU,1068
9
+ pinetext-0.1.2.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,,