Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs, TTS, answer streaming, web search and perplexity clone #457

Merged
merged 92 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
470c7f1
f
rmusser01 Dec 5, 2024
5586cc6
LINKS
rmusser01 Dec 7, 2024
b56ec96
Update VLM.md
rmusser01 Dec 7, 2024
5f39add
Merge branch 'dev' of https://github.com/rmusser01/tldw into dev
rmusser01 Dec 7, 2024
5b4a87f
f
rmusser01 Dec 9, 2024
5cedc10
f
rmusser01 Dec 9, 2024
3a34bc2
Merge branch 'dev' of https://github.com/rmusser01/tldw into dev
rmusser01 Dec 9, 2024
46d074e
f
rmusser01 Dec 9, 2024
23d0f0c
links
rmusser01 Dec 12, 2024
99e3f73
links
rmusser01 Dec 12, 2024
7796c56
Scrollbars elude me
rmusser01 Dec 14, 2024
4664132
Update Article_Extractor_Lib.py
rmusser01 Dec 14, 2024
edf8558
f
rmusser01 Dec 14, 2024
97df047
uhhh
rmusser01 Dec 18, 2024
f50e4f2
uhh
rmusser01 Dec 19, 2024
d96dd8d
Update README.md
rmusser01 Dec 19, 2024
aae29a6
sure do love the reliability of PGE
rmusser01 Dec 21, 2024
15d1c65
uhhh
rmusser01 Dec 22, 2024
4c5b787
Fuck PGE
rmusser01 Dec 23, 2024
5c4ba51
search
rmusser01 Dec 23, 2024
6083cdc
Update WebSearch_APIs.py
rmusser01 Dec 23, 2024
dbb782a
Config settings + defaults for google search
rmusser01 Dec 24, 2024
f8c299d
DDG
rmusser01 Dec 24, 2024
f407bce
Create Versioning_Scheme.jpg
rmusser01 Dec 24, 2024
6faf606
searx
rmusser01 Dec 24, 2024
274ac28
why does the test fail?
rmusser01 Dec 24, 2024
30b9a4c
search
rmusser01 Dec 25, 2024
11814d1
search APIs
rmusser01 Dec 27, 2024
c920304
ddg
rmusser01 Dec 27, 2024
737bc31
Update WebSearch_APIs.py
rmusser01 Dec 27, 2024
9d78c72
p
rmusser01 Dec 27, 2024
2f48ffc
F
rmusser01 Dec 28, 2024
cb63eb9
search parsing + building the chain & prompts
rmusser01 Dec 28, 2024
f108cd7
little bit closer to perplexity
rmusser01 Dec 29, 2024
e1520a5
f
rmusser01 Dec 29, 2024
067826d
f
rmusser01 Dec 29, 2024
65f9ef1
Fix the github workflow error?
rmusser01 Dec 29, 2024
b4a74bc
?
rmusser01 Dec 29, 2024
49c47f2
Update test_chromadb.py
rmusser01 Dec 29, 2024
c029244
Update test_chromadb.py
rmusser01 Dec 29, 2024
af28e7b
Update test_chromadb.py
rmusser01 Dec 30, 2024
f1f7d3a
Update Utils.py
rmusser01 Dec 30, 2024
e4a8a54
Update python-app.yml
rmusser01 Dec 30, 2024
88d8c67
Update python-app.yml
rmusser01 Dec 30, 2024
5cc8181
Update python-app.yml
rmusser01 Dec 30, 2024
0c26bfd
amithatretarded
rmusser01 Dec 30, 2024
ddfeb97
Merge branch 'dev' of https://github.com/rmusser01/tldw into dev
rmusser01 Dec 30, 2024
c4ecdef
Wow. I'll take that as a yes.
rmusser01 Dec 30, 2024
7a9e25a
more progress on perplexity
rmusser01 Dec 30, 2024
d09c8ae
checkpoint
rmusser01 Dec 31, 2024
a31bf68
Update WebSearch_APIs.py
rmusser01 Dec 31, 2024
7b29c1e
DDG works
rmusser01 Dec 31, 2024
55328ba
Fuck Yea it works. Perplexity pipeline is in.
rmusser01 Dec 31, 2024
a9a5ceb
sweet now its working
rmusser01 Dec 31, 2024
dd8ec0d
Update WebSearch_APIs.py
rmusser01 Dec 31, 2024
f46aa0e
f
rmusser01 Dec 31, 2024
e6f5695
sweet, it works. Now to add rate limiting...
rmusser01 Dec 31, 2024
b24c8b2
websearch docs
rmusser01 Dec 31, 2024
9c6c7f6
added 0.3-> 1.5 second pauses in requests.
rmusser01 Dec 31, 2024
63dbc1f
well config is 'broken' but better, will break it more though. Also s…
rmusser01 Jan 1, 2025
4bf6179
Update LLM_API_Calls.py
rmusser01 Jan 1, 2025
dfb49cf
eh
rmusser01 Jan 1, 2025
760645e
Update RAG_Notes.md
rmusser01 Jan 1, 2025
674c7e8
Merge branch 'dev' of https://github.com/rmusser01/tldw into dev
rmusser01 Jan 1, 2025
c9286ac
streaming is now in and works. Need to update the surrounding chat fu…
rmusser01 Jan 1, 2025
00f5591
fix local LLM config loads
rmusser01 Jan 1, 2025
fbbb97f
At least one works
rmusser01 Jan 1, 2025
8042e06
Update Utils.py
rmusser01 Jan 1, 2025
3f37d00
Update Backup_Config.txt
rmusser01 Jan 1, 2025
070bfbe
chat regen works
rmusser01 Jan 1, 2025
635a5cd
TTS support for Alltalk, ElevenLabs, and OpenAI.
rmusser01 Jan 2, 2025
67f8ae3
Sweet.
rmusser01 Jan 2, 2025
8004772
Update Character_Chat_tab.py
rmusser01 Jan 2, 2025
6b6268c
and we have TTS in all the singular chats! Fuck Yea.
rmusser01 Jan 2, 2025
42f5ad3
Update TTS_Providers.py
rmusser01 Jan 2, 2025
be9f4a3
sanity checkpoint
rmusser01 Jan 2, 2025
1b1ef59
Update WebSearch_APIs.py
rmusser01 Jan 2, 2025
b6936b2
Update WebSearch_tab.py
rmusser01 Jan 2, 2025
ce8e80d
Update WebSearch_tab.py
rmusser01 Jan 2, 2025
0f1b3f6
f
rmusser01 Jan 3, 2025
d7f5f24
f
rmusser01 Jan 3, 2025
1b82823
f
rmusser01 Jan 3, 2025
7d019b3
meh, i'll take it.
rmusser01 Jan 3, 2025
e3d2d44
w.o.w.
rmusser01 Jan 3, 2025
409de88
dollar store perplexity.
rmusser01 Jan 3, 2025
3337ed1
Update WebSearch.md
rmusser01 Jan 3, 2025
b8931d3
closer
rmusser01 Jan 4, 2025
3fe8cab
f
rmusser01 Jan 4, 2025
4af4c68
Update Character_Chat_tab.py
rmusser01 Jan 4, 2025
5677b32
Update Character_Chat_tab.py
rmusser01 Jan 4, 2025
872d6ad
finallly
rmusser01 Jan 4, 2025
5e2c2d5
BREAKING CONFIG CHANGE!!!
rmusser01 Jan 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ jobs:
- name: Test ChromaDB lib functions with pytest
run: |
pwd
cd ./Tests/ChromaDB
pytest test_chromadb.py
ls
ls ./Config_Files
cd ./Tests/ChromaDB/
pytest ./test_chromadb.py

- name: Test RAG lib functions with pytest
run: |
Expand All @@ -59,3 +61,8 @@ jobs:
pwd
cd ./Tests/Utils
pytest test_utils.py

- name: Test tldw runs
run: |
pwd
python summarize.py -h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pipeline:
params:
clustering: AgglomerativeClustering
embedding: /FULL/PATH/TO/SCRIPT/tldw/App_Function_Libraries/models/pyannote_model_wespeaker-voxceleb-resnet34-LM.bin #models/pyannote_model_wespeaker-voxceleb-resnet34-LM.bin
segmentation: /FULL/PATH/TO/SCRIPT/tldw/App_Function_Libraries/models/pyannote_model_segmentation-3.0.bin #models/pyannote_model_segmentation-3.0.bin

params:
segmentation:
min_duration_off: 0.0
clustering:
method: centroid
min_cluster_size: 12
threshold: 0.7045654963945799
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,20 @@ def simplified_geval(transcript: str, summary: str, api_name: str, api_key: str,

Overall Assessment: [Your overall assessment of the summary's quality]
"""

# FIXME - Add g_eval_model to config.txt
# g_eval_model = loaded_config[][]
try:
result = chat_api_call(
api_name,
api_key,
prompt,
"",
temp=temp,
system_message="You are a helpful AI assistant tasked with evaluating summaries."
system_message="You are a helpful AI assistant tasked with evaluating summaries.",
streaming=False,
minp=None,
maxp=None,
model=None
)
except Exception as e:
return detailed_api_error(api_name, e)
Expand Down
2 changes: 1 addition & 1 deletion App_Function_Libraries/Benchmarks_Evaluations/ms_g_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def geval_summarization(
temp = 0.7
logging.info(f"Debug - geval_summarization Function - API Endpoint: {api_endpoint}")
try:
response = chat_api_call(api_endpoint, api_key, prompt_with_src_and_gen, "", temp, system_message)
response = chat_api_call(api_endpoint, api_key, prompt_with_src_and_gen, "", temp, system_message, streaming=False, minp=None, maxp=None, model=None)
except Exception as e:
raise ValueError(f"Unsupported API endpoint: {api_endpoint}")
except RetryError:
Expand Down
14 changes: 13 additions & 1 deletion App_Function_Libraries/Character_Chat/Character_Chat_Lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,25 @@ def extract_character_id(choice: str) -> int:
"""Extract the character ID from the dropdown selection string."""
log_counter("extract_character_id_attempt")
try:
character_id = int(choice.split('(ID: ')[1].rstrip(')'))
logging.debug(f"Choice received: {choice}") # Debugging line
if not choice:
raise ValueError("No choice provided.")

if '(ID: ' not in choice or ')' not in choice:
raise ValueError(f"Invalid choice format: {choice}")

# Extract the ID part
id_part = choice.split('(ID: ')[1]
character_id = int(id_part.rstrip(')'))

logging.debug(f"Extracted character ID: {character_id}") # Debugging line
log_counter("extract_character_id_success")
return character_id
except Exception as e:
log_counter("extract_character_id_error", labels={"error": str(e)})
raise


def load_character_wrapper(character_id: int, user_name: str) -> Tuple[Dict[str, Any], List[Tuple[Optional[str], str]], Optional[Image.Image]]:
"""Wrapper function to load character and image using the extracted ID."""
log_counter("load_character_wrapper_attempt")
Expand Down
54 changes: 33 additions & 21 deletions App_Function_Libraries/Chat/Chat_Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,23 @@
# Functions:

def approximate_token_count(history):
total_text = ''
for user_msg, bot_msg in history:
if user_msg:
total_text += user_msg + ' '
if bot_msg:
total_text += bot_msg + ' '
total_tokens = len(total_text.split())
return total_tokens

def chat_api_call(api_endpoint, api_key, input_data, prompt, temp, system_message=None):
try:
total_text = ''
for user_msg, bot_msg in history:
if user_msg:
total_text += user_msg + ' '
if bot_msg:
total_text += bot_msg + ' '
total_tokens = len(total_text.split())
return total_tokens
except Exception as e:
logging.error(f"Error calculating token count: {str(e)}")
return 0


# FIXME - add model parameter
def chat_api_call(api_endpoint, api_key, input_data, prompt, temp, system_message, streaming, minp=None, maxp=None, model=None):
logging.info(f"Debug - Chat API Call - API Endpoint: {api_endpoint}")
log_counter("chat_api_call_attempt", labels={"api_endpoint": api_endpoint})
start_time = time.time()
if not api_key:
Expand All @@ -50,18 +57,22 @@ def chat_api_call(api_endpoint, api_key, input_data, prompt, temp, system_messag
logging.info(f"Debug - Chat API Call - API Key: {api_key}")
logging.info(f"Debug - Chat chat_api_call - API Endpoint: {api_endpoint}")
if api_endpoint.lower() == 'openai':
response = chat_with_openai(api_key, input_data, prompt, temp, system_message)
response = chat_with_openai(api_key, input_data, prompt, temp, system_message, streaming, minp, maxp, model)

elif api_endpoint.lower() == 'anthropic':
# Retrieve the model from config
loaded_config_data = load_and_log_configs()
model = loaded_config_data['models']['anthropic'] if loaded_config_data else None
if not model:
model = loaded_config_data['anthropic_api']['model']
response = chat_with_anthropic(
api_key=api_key,
input_data=input_data,
model=model,
custom_prompt_arg=prompt,
system_prompt=system_message
max_retries=3,
retry_delay=5,
system_prompt=system_message,
streaming=streaming,
)

elif api_endpoint.lower() == "cohere":
Expand Down Expand Up @@ -133,7 +144,7 @@ def chat_api_call(api_endpoint, api_key, input_data, prompt, temp, system_messag


def chat(message, history, media_content, selected_parts, api_endpoint, api_key, prompt, temperature,
system_message=None):
system_message=None, streaming=False, minp=None, maxp=None, model=None):
log_counter("chat_attempt", labels={"api_endpoint": api_endpoint})
start_time = time.time()
try:
Expand Down Expand Up @@ -172,12 +183,15 @@ def chat(message, history, media_content, selected_parts, api_endpoint, api_key,
logging.debug(f"Debug - Chat Function - Prompt: {prompt}")

# Use the existing API request code based on the selected endpoint
response = chat_api_call(api_endpoint, api_key, input_data, prompt, temp, system_message)
response = chat_api_call(api_endpoint, api_key, input_data, prompt, temp, system_message, streaming, minp=None, maxp=None, model=None)

chat_duration = time.time() - start_time
log_histogram("chat_duration", chat_duration, labels={"api_endpoint": api_endpoint})
log_counter("chat_success", labels={"api_endpoint": api_endpoint})
return response
if streaming:
return response
else:
chat_duration = time.time() - start_time
log_histogram("chat_duration", chat_duration, labels={"api_endpoint": api_endpoint})
log_counter("chat_success", labels={"api_endpoint": api_endpoint})
return response
except Exception as e:
log_counter("chat_error", labels={"api_endpoint": api_endpoint, "error": str(e)})
logging.error(f"Error in chat function: {str(e)}")
Expand Down Expand Up @@ -374,7 +388,6 @@ def update_chat_content(selected_item, use_content, use_summary, use_prompt, ite

CHARACTERS_FILE = Path('.', 'Helper_Scripts', 'Character_Cards', 'Characters.json')


def save_character(character_data):
log_counter("save_character_attempt")
start_time = time.time()
Expand Down Expand Up @@ -435,7 +448,6 @@ def load_characters():
return {}



def get_character_names():
log_counter("get_character_names_attempt")
start_time = time.time()
Expand Down
19 changes: 19 additions & 0 deletions App_Function_Libraries/Chat/Chat_Pipeline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Chat_Pipeline.py
#
# Description: This file contains functions related to the prompt modification pipeline, available as a means of
# complex prompt modification/replacement without modification of original intent/messaging.
#
# Imports
import os
#
# 3rd-party Libraries
#
# Local Imports
#
#######################################################################################################################
#
# Functions:

#
# End of Chat_Pipeline.py
#######################################################################################################################
25 changes: 14 additions & 11 deletions App_Function_Libraries/DB/Character_Chat_DB.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,20 @@ def add_character_card(card_data: Dict[str, Any]) -> Optional[int]:

def get_character_cards() -> List[Dict]:
"""Retrieve all character cards from the database."""
logging.debug(f"Fetching characters from DB: {chat_DB_PATH}")
conn = sqlite3.connect(chat_DB_PATH)
cursor = conn.cursor()
cursor.execute("SELECT * FROM CharacterCards")
rows = cursor.fetchall()
columns = [description[0] for description in cursor.description]
conn.close()
characters = [dict(zip(columns, row)) for row in rows]
#logging.debug(f"Characters fetched from DB: {characters}")
return characters

try:
logging.debug(f"Fetching characters from DB: {chat_DB_PATH}")
conn = sqlite3.connect(chat_DB_PATH)
cursor = conn.cursor()
cursor.execute("SELECT * FROM CharacterCards")
rows = cursor.fetchall()
columns = [description[0] for description in cursor.description]
conn.close()
characters = [dict(zip(columns, row)) for row in rows]
logging.debug(f"Characters fetched from DB: {characters}")
return characters
except Exception as e:
logging.error(f"Error fetching character cards: {e}")
return []

def get_character_card_by_id(character_id: Union[int, Dict[str, Any]]) -> Optional[Dict[str, Any]]:
"""
Expand Down
7 changes: 7 additions & 0 deletions App_Function_Libraries/Gradio_Related.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
create_utilities_yt_video_tab
from App_Function_Libraries.Gradio_UI.Video_transcription_tab import create_video_transcription_tab
from App_Function_Libraries.Gradio_UI.View_tab import create_manage_items_tab
from App_Function_Libraries.Gradio_UI.WebSearch_tab import create_websearch_tab
from App_Function_Libraries.Gradio_UI.Website_scraping_tab import create_website_scraping_tab
from App_Function_Libraries.Gradio_UI.Workflows_tab import chat_workflows_tab
from App_Function_Libraries.Gradio_UI.View_DB_Items_tab import create_view_all_mediadb_with_versions_tab, \
Expand Down Expand Up @@ -403,6 +404,10 @@ def launch_ui(share_public=None, server_mode=False):
padding: 10px;
margin-top: 10px;
}
.scrollable-textbox textarea {
height: 600px !important;
overflow-y: auto !important;
}
"""

config = load_and_log_configs()
Expand Down Expand Up @@ -464,6 +469,8 @@ def launch_ui(share_public=None, server_mode=False):
create_chat_interface_four()
chat_workflows_tab()

with gr.TabItem("Web Search & Review", id="websearch group", visible=True):
create_websearch_tab()
with gr.TabItem("Character Chat", id="character chat group", visible=True):
create_character_card_interaction_tab()
create_character_chat_mgmt_tab()
Expand Down
Loading
Loading