From eb720f325f91b19a90036892c77ce4bda6052400 Mon Sep 17 00:00:00 2001 From: Sermet Pekin Date: Thu, 8 Aug 2024 22:33:34 +0300 Subject: [PATCH] fix obscure --- .readthedocs.yaml | 3 ++- README.md | 22 +++++++++++----------- evdschat/core/chat.py | 5 +++++ evdschat/model/chatters.py | 2 +- main.py | 9 +++++---- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index b9dcc1c..c2809d0 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -18,7 +18,8 @@ build: # Build documentation in the "docs/" directory with Sphinx sphinx: configuration: docs/source/conf.py - + fail_on_warning : True + # Optionally build your docs in additional formats such as PDF and ePub # formats: # - pdf diff --git a/README.md b/README.md index e197c8f..43fb301 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,16 @@ python3.11 -m pip install evdschat -U python3.10 -m pip install evdschat -U ``` +## Defining Api Keys ( .env file ) + +```bash + # .env file content + + OPENAI_API_KEY = "sk-proj-ABCDEFGIJKLMNOPQRSTUXVZ" + EVDS_API_KEY=ABCDEFGIJKLMNOP + +``` + ## Example ```python @@ -56,21 +66,11 @@ prompt = ''' result, notes = chat(prompt, test=False) print(result) ``` -## Defining Api Keys ( .env file ) - -```bash - # .env file content - - OPENAI_API_KEY = "sk-proj-ABCDEFGIJKLMNOPQRSTUXVZ" - EVDS_API_KEY=ABCDEFGIJKLMNOP - -``` ## New in this version -- Replaced some modern features to support earlier Python versions. - Now supports Python versions 3.9 through 3.12. + ## License diff --git a/evdschat/core/chat.py b/evdschat/core/chat.py index 3183c5a..241b1d1 100644 --- a/evdschat/core/chat.py +++ b/evdschat/core/chat.py @@ -24,6 +24,9 @@ class GotNoneFromGetter(BaseException): ... +class GotUndefinedResult(BaseException): ... + + def chat( prompt: str, getter: ModelAbstract = OpenAI(), @@ -65,6 +68,8 @@ def chat( Please try again later or check documentation for new API URLs""" ) + if not isinstance(res , tuple ) or len(res ) != 2 : + raise GotUndefinedResult() result, notes = res return result, notes diff --git a/evdschat/model/chatters.py b/evdschat/model/chatters.py index 5377194..21efdfc 100644 --- a/evdschat/model/chatters.py +++ b/evdschat/model/chatters.py @@ -64,7 +64,7 @@ def post(self, prompt: str) -> Union[dict, bool]: def obscure(self, string: str) -> str: nstr = [] - for i, char in enumerate(string): + for i, char in enumerate(string.split()): if i % 3 == 1: nstr.append(char) else: diff --git a/main.py b/main.py index 03239cc..afd2b00 100644 --- a/main.py +++ b/main.py @@ -22,7 +22,8 @@ """ -# res , notes = chat(prompt, debug=True ) -res = chat(prompt, debug=False ) -print(res , type(res)) -# res.to_excel('prompt1.xlsx') +res, notes = chat(prompt, debug=False) + +print(res, type(res)) +print(notes) +res.to_excel("prompt1.xlsx")