basic submodule working

This commit is contained in:
Fraser
2023-07-06 09:56:07 -04:00
parent c589ca01d3
commit 361f1e1499
3 changed files with 18 additions and 2 deletions
+6 -2
View File
@@ -27,6 +27,10 @@ ENCODER = tiktoken.get_encoding("cl100k_base")
DEBUG_PRINT = True
def set_debug_print(val: bool):
global DEBUG_PRINT
DEBUG_PRINT = val
# --------------------------------- prompt code --------------------------------
@@ -187,10 +191,10 @@ def talk_to_robot(index, query: str, history: List[Dict[str, str]], k: int = STA
yield from (json.dumps(block) for block in talk_to_robot_internal(index, query, history, k, log))
# wayyy simplified api
def talk_to_robot_simple(index, query: str):
def talk_to_robot_simple(index, query: str, log: Callable = print):
res = {'response': ''}
for block in talk_to_robot_internal(index, query, []):
for block in talk_to_robot_internal(index, query, [], log = log):
if block['state'] == 'loading' and block['phase'] == 'semantic' and 'citations' in block:
citations = {}
for i, c in enumerate(block['citations']):
+9
View File
@@ -0,0 +1,9 @@
import sys
from pathlib import Path
sys.path = [str(Path(__file__).parent.parent)] + sys.path
from env import PINECONE_INDEX
from chat import talk_to_robot_simple, set_debug_print
set_debug_print(False)
print(talk_to_robot_simple(PINECONE_INDEX, 'Hello.', log = lambda x: None))
+3
View File
@@ -0,0 +1,3 @@
```bash
pipenv run python3 prompteng/prompteng.py
```