Skip to content

Commit

Permalink
BREAKING CONFIG CHANGE!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
rmusser01 committed Jan 4, 2025
1 parent 872d6ad commit 5e2c2d5
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 26 deletions.
22 changes: 12 additions & 10 deletions App_Function_Libraries/Chat/Chat_Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@
# 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
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
Expand Down Expand Up @@ -384,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 @@ -445,7 +448,6 @@ def load_characters():
return {}



def get_character_names():
log_counter("get_character_names_attempt")
start_time = time.time()
Expand Down
4 changes: 0 additions & 4 deletions App_Function_Libraries/Gradio_UI/Character_Chat_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,10 +801,6 @@ def regenerate_last_message(
save_status = f"Error regenerating message: {str(e)}"
return history, save_status # Return original history if an error occurs


def toggle_chat_file_upload():
return gr.update(visible=True)

def save_untracked_chat_action(history, char_data):
if not char_data or not history:
return "No chat to save or character not selected."
Expand Down
38 changes: 26 additions & 12 deletions Config_Files/Backup_Config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ anthropic_api_key = <anthropic_api_key>
anthropic_model = claude-3-5-sonnet-20240620
anthropic_streaming = True
anthropic_temperature = 0.7
anthropic_top_p = 0.95
anthropic_min_p = 0.05
#
cohere_api_key = <cohere_api_key>
cohere_model = command-r-plus
Expand All @@ -18,6 +20,7 @@ openai_api_key = <openai_api_key>
openai_model = gpt-4o
openai_streaming = False
openai_temperature = 0.7
openai_top_p = 0.95
#
huggingface_api_key = <huggingface_api_key>
huggingface_model = meta-llama/Llama-3.1-70B-Instruct
Expand Down Expand Up @@ -142,16 +145,17 @@ default_openai_tts_output_format = mp3
#
# ElevenLabs TTS Settings
default_eleven_tts_voice = pNInz6obpgDQGcFmaJgB
default_eleven_tts_model = FIXME
default_eleven_tts_language_code = FIXME
default_eleven_tts_voice_stability = FIXME
default_eleven_tts_voice_similiarity_boost = FIXME
default_eleven_tts_voice_style = FIXME
default_eleven_tts_voice_use_speaker_boost = FIXME
default_eleven_tts_voice_pronunciation_dictionary_locators_dict_id = FIXME
default_eleven_tts_voice_pronunciation_dictionary_locators_version_id = FIXME
default_eleven_tts_model =
default_eleven_tts_language_code =
default_eleven_tts_voice_stability =
default_eleven_tts_voice_similiarity_boost =
default_eleven_tts_voice_style =
default_eleven_tts_voice_use_speaker_boost =
default_eleven_tts_voice_pronunciation_dictionary_locators_dict_id =
default_eleven_tts_voice_pronunciation_dictionary_locators_version_id =
default_eleven_tts_speed = 1
default_eleven_tts_output_format = FIXME
# Output options: 'mp3_22050_32', 'mp3_44100_32', 'mp3_44100_64', 'mp3_44100_96', 'mp3_44100_128', 'mp3_44100_192', 'pcm_16000', 'pcm_22050', 'pcm_24000', 'pcm_44100', 'ulaw_8000'
default_eleven_tts_output_format = mp3_44100_128
# Google TTS Settings
default_google_tts_model = FIXME
default_google_tts_voice = FIXME
Expand All @@ -160,6 +164,14 @@ default_google_tts_speed = 1
# MS Edge TTS Settings
edge_tts_voice = FIXME
#
# GPT-Sovits
#
# AllTalk TTS Settings
default_alltalk_tts_speed = 1.0
default_alltalk_tts_voice = alloy
default_alltalk_tts_model = alltalk
default_alltalk_tts_output_format = mp3
alltalk_api_ip = http://127.0.0.1:7851/v1/audio/speech

[Search-Engines]
# Search Defaults
Expand All @@ -179,9 +191,11 @@ search_result_display_metadata = False
search_result_save_to_db = True
# How you want the results to be written, think 'style' or voice
search_result_analysis_tone =
relevance_analysis_llm = openai
final_answer_llm = openai
#### Search Engines #####
# Baidu
search_engine_api_key_baidu = <baidu_api_key>>
search_engine_api_key_baidu = 1e1b1b1b1b1b1b1b1
#
# Bing
search_engine_api_url_bing = https://api.bing.microsoft.com/v7.0/search
Expand Down Expand Up @@ -224,8 +238,8 @@ search_engine_searx_api = https://search.rhscz.eu/
# Tavily
search_engine_api_key_tavily = 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
# Yandex
search_engine_api_key_yandex = <yandex_api_key>>
search_engine_id_yandex = <yandex_search_engine_id>>
search_engine_api_key_yandex = 1e1b1b1b1b1b1b1b1
search_engine_id_yandex = 1e1b1b1b1b1b1b1b1

[Prompts]
prompt_sample = "What is the meaning of life?"
Expand Down
76 changes: 76 additions & 0 deletions Docs/Design/WebSearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,79 @@ Structure/approach taken from https://github.com/deedy5/duckduckgo_search

#### PubMedCentral Search
- https://www.ncbi.nlm.nih.gov/home/develop/api/



### Prompts used:

sub_question_generation_prompt =
```
You are an AI assistant that helps generate search queries. Given an original query, suggest alternative search queries that could help find relevant information. Your goal is to generate queries that are diverse, specific, and highly relevant to the original query, ensuring comprehensive coverage of the topic.
Important instructions:
1. Generate between 2 and 6 queries unless a fixed count is specified. Generate more queries for complex or multifaceted topics and fewer for simple or straightforward ones.
2. Ensure the queries are diverse, covering different aspects or perspectives of the original query, while remaining highly relevant to its core intent.
3. Prefer specific queries over general ones, as they are more likely to yield targeted and useful results.
4. If the query involves comparing two topics, generate separate queries for each topic.
5. If previous queries and an answer are provided, generate new queries that address the shortcomings of the previous answer and avoid repeating the previous queries.
6. If the original query is broad or ambiguous, generate queries that explore specific subtopics or clarify the intent.
7. If the query is too specific or unclear, generate queries that explore related or broader topics to ensure useful results.
8. Return the queries as a JSON array in the format ["query_1", "query_2", ...].
Examples:
1. For the query "What are the benefits of exercise?", generate queries like:
["health benefits of physical activity", "mental health benefits of exercise", "long-term effects of regular exercise", "how exercise improves cardiovascular health", "role of exercise in weight management"]
2. For the query "Compare Python and JavaScript", generate queries like:
["key features of Python programming language", "advantages of JavaScript for web development", "use cases for Python vs JavaScript", "performance comparison of Python and JavaScript", "ease of learning Python vs JavaScript"]
3. For the query "How does climate change affect biodiversity?", generate queries like:
["impact of climate change on species extinction", "effects of global warming on ecosystems", "role of climate change in habitat loss", "how rising temperatures affect marine biodiversity", "climate change and its impact on migratory patterns"]
4. For the query "Best practices for remote work", generate queries like:
["tips for staying productive while working from home", "how to maintain work-life balance in remote work", "tools for effective remote team collaboration", "managing communication in remote teams", "ergonomic setup for home offices"]
5. For the query "What is quantum computing?", generate queries like:
["basic principles of quantum computing", "applications of quantum computing in real-world problems", "difference between classical and quantum computing", "key challenges in developing quantum computers", "future prospects of quantum computing"]
Original query: {original_query}
#
search_result_relevance_eval_prompt = Given the following search results for the user's question: "{original_question}" and the generated sub-questions: {sub_questions}, evaluate the relevance of the search result to the user's question.
Explain your reasoning for selection.
Search Results:
{content}
Instructions:
1. You MUST only answer TRUE or False while providing your reasoning for your answer.
2. A result is relevant if the result most likely contains comprehensive and relevant information to answer the user's question.
3. Provide a brief reason for selection.
You MUST respond using EXACTLY this format and nothing else:
Selected Answer: [True or False]
Reasoning: [Your reasoning for the selections]
```

analyze_search_results_prompt =
```
Generate a comprehensive, well-structured, and informative answer for a given question,
using ONLY the information found in the provided web Search Results (URL, Page Title, Summary).
Use an unbiased, journalistic tone, adapting the level of formality to match the user’s question.
• Cite your statements using [number] notation, placing citations at the end of the relevant sentence.
• Only cite the most relevant results. If multiple sources support the same point, cite all relevant sources [e.g., 1, 2, 3].
• If sources conflict, present both perspectives clearly and cite the respective sources.
• If different sources refer to different entities with the same name, provide separate answers.
• Do not add any external or fabricated information.
• Do not include URLs or a reference section; cite inline with [number] format only.
• Do not repeat the question or include unnecessary redundancy.
• Use markdown formatting (e.g., **bold**, bullet points, ## headings) to organize the information.
• If the provided results are insufficient to answer the question, explicitly state what information is missing or unclear.
Structure your answer like this:
1. **Short introduction**: Briefly summarize the topic (1–2 sentences).
2. **Bulleted points**: Present key details, each with appropriate citations.
3. **Conclusion**: Summarize the findings or restate the core answer (with citations if needed).
Example:
1. **Short introduction**: This topic explores the impact of climate change on agriculture.
2. **Bulleted points**:
- Rising temperatures have reduced crop yields in some regions [1].
- Changes in rainfall patterns are affecting irrigation practices [2, 3].
3. **Conclusion**: Climate change poses significant challenges to global agriculture [1, 2, 3].
<context>
{concatenated_texts}
</context>
---------------------
Make sure to match the language of the user's question.
Question: {question}
Answer (in the language of the user's question):
```

0 comments on commit 5e2c2d5

Please sign in to comment.