Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
kreneskyp committed Apr 13, 2023
1 parent 1ab4dd8 commit 593227a
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
OPENAI_API_KEY=

# Pinecone
PINECONE_API_KEY=
PINECONE_ENV=

# search
GOOGLE_API_KEY=
GOOGLE_CX_ID=
WOLFRAM_APP_ID=
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ direction and halt the process if it goes off the rails.**
- PostgreSQL 14.4
- Graphql
- React 18
- Framework to support remote and local AI models including GPT-4
- Integrated with OpenAI GPT models
- Plugin architecture to support extending agent functionality (e.g. web browsing, debugging code, etc)
- Generic framework for vector database based agent memory
- Pinecone
Expand All @@ -84,6 +84,26 @@ git clone https://github.com/kreneskyp/ix.git
cd ix
```

Setup config in `.env`

```bash
cp .env.template .env
```

```
OPENAI_API_KEY=YOUR_KEY_HERE
# Pinecone
PINECONE_API_KEY=
PINECONE_ENV=
# search
GOOGLE_API_KEY=
GOOGLE_CX_ID=
WOLFRAM_APP_ID=
```


Build and run the dev image:

```
Expand Down
22 changes: 22 additions & 0 deletions ix/commands/tests/test_wolfram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest

from ix.commands.wolfram import search_wolfram


class TestSearchWolfram:
def test_search_wolfram_with_valid_query(self):
query = "What is the capital of France?"
results = search_wolfram(query)
assert len(results) > 0
assert all(isinstance(result, tuple) for result in results)

def test_search_wolfram_with_empty_query(self):
query = ""
with pytest.raises(ValueError):
search_wolfram(query)

def test_search_wolfram_with_missing_app_id(self, monkeypatch):
monkeypatch.delenv("WOLFRAM_APP_ID", raising=False)
query = "What is the capital of France?"
with pytest.raises(ValueError):
search_wolfram(query)
23 changes: 23 additions & 0 deletions ix/commands/wolfram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from typing import Callable, Any, List, Tuple
import os
import wolframalpha

from ix.commands import command


@command(name="search_wolfram", description="Search Wolfram.")
def search_wolfram(search_string: str) -> List[Tuple[str, str]]:
"""Searches Wolfram for the given search string and returns a list of (title, plaintext) tuples."""
app_id = os.environ.get("WOLFRAM_APP_ID")
if not app_id:
raise ValueError("WOLFRAM_APP_ID environment variable not set.")
if not search_string:
raise ValueError("search_string is required")
client = wolframalpha.Client(app_id)
print(search_string)
res = client.query(search_string)
results = []
for pod in res.pods:
for subpod in pod.subpods:
results.append((pod.title, subpod.plaintext))
return results
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ipython==8.12.0
django_extensions==3.2.1
pinecone-client==2.2.1
tiktoken==0.3.3
wolframalpha==5.0.0

0 comments on commit 593227a

Please sign in to comment.