Spaces:
Sleeping
Sleeping
yash bhaskar
commited on
Commit
·
b54f15f
1
Parent(s):
7f02691
Modifying Config Files
Browse files
Agents/rankerAgent.py
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
import json
|
|
|
|
| 2 |
from together import Together
|
| 3 |
|
| 4 |
def rerank_best_answer(json_files, config_file='config.json', model="meta-llama/Llama-3-8b-chat-hf"):
|
| 5 |
# Load API key from configuration file
|
| 6 |
-
with open(config_file, 'r') as file:
|
| 7 |
-
config = json.load(file)
|
| 8 |
|
| 9 |
-
|
|
|
|
| 10 |
if not together_ai_key:
|
| 11 |
-
raise ValueError("TOGETHER_AI
|
| 12 |
|
| 13 |
# Initialize Together client
|
| 14 |
client = Together(api_key=together_ai_key)
|
|
@@ -81,12 +81,10 @@ Just Output the best_answer from above JSON and nothing else.
|
|
| 81 |
|
| 82 |
def rankerAgent(prompt, config_file='config.json', model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo"):
|
| 83 |
# Load API key from configuration file
|
| 84 |
-
|
| 85 |
-
config = json.load(file)
|
| 86 |
-
|
| 87 |
-
together_ai_key = config.get("TOGETHER_AI")
|
| 88 |
if not together_ai_key:
|
| 89 |
-
raise ValueError("TOGETHER_AI
|
|
|
|
| 90 |
|
| 91 |
# Initialize Together client
|
| 92 |
client = Together(api_key=together_ai_key)
|
|
@@ -131,28 +129,3 @@ Just Output the best_answer from above JSON and nothing else.
|
|
| 131 |
|
| 132 |
return response_bestModel.choices[0].message.content, response_bestAnswer.choices[0].message.content
|
| 133 |
|
| 134 |
-
|
| 135 |
-
# # Usage example
|
| 136 |
-
# json_files = ["../QnA_Eval/Responses/BOW_1_2_top_100_response.json",
|
| 137 |
-
# "../QnA_Eval/Responses/BOW_1_2_top_100_modified_response.json",
|
| 138 |
-
# "../QnA_Eval/Responses/tf-idf_1_2_top_100_response.json",
|
| 139 |
-
# "../QnA_Eval/Responses/tf-idf_1_2_top_100_modified_response.json",
|
| 140 |
-
# "../QnA_Eval/Responses/bm25_1_2_top_100_response.json",
|
| 141 |
-
# "../QnA_Eval/Responses/bm25_1_2_top_100_modified_response.json",
|
| 142 |
-
# "../QnA_Eval/Responses/open_source_1_2_top_100_response.json",
|
| 143 |
-
# "../QnA_Eval/Responses/open_source_1_2_top_100_modified_response.json",
|
| 144 |
-
# "../QnA_Eval/Responses/vision_1_2_top_100_response.json",
|
| 145 |
-
# "../QnA_Eval/Responses/vision_1_2_top_100_modified_response.json",
|
| 146 |
-
# "../QnA_Eval/Responses/ZeroShot_response.json",
|
| 147 |
-
# "../QnA_Eval/Responses/WikiAgent_response.json",
|
| 148 |
-
# "../QnA_Eval/Responses/WikiAgent_response_modified.json",
|
| 149 |
-
# "../QnA_Eval/Responses/LlamaAgent_response.json",
|
| 150 |
-
# "../QnA_Eval/Responses/LlamaAgent_response_modified.json",
|
| 151 |
-
# "../QnA_Eval/Responses/tf_idf_bm25_open_1_2_top_100_combined_response.json", "../QnA_Eval/Responses/tf_idf_bm25_open_1_2_top_100_combined_modified_response.json", "../QnA_Eval/Responses/tf_idf_bm25_open_1_2_top_100_combined_both_response.json"]
|
| 152 |
-
|
| 153 |
-
# config_file = "../config.json"
|
| 154 |
-
|
| 155 |
-
# result = rerank_best_answer(json_files, config_file)
|
| 156 |
-
|
| 157 |
-
# with open("reranked_best_answers_1_2.json", 'w') as file:
|
| 158 |
-
# json.dump(result, file, indent=4, ensure_ascii=False)
|
|
|
|
| 1 |
import json
|
| 2 |
+
import os
|
| 3 |
from together import Together
|
| 4 |
|
| 5 |
def rerank_best_answer(json_files, config_file='config.json', model="meta-llama/Llama-3-8b-chat-hf"):
|
| 6 |
# Load API key from configuration file
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
|
| 9 |
+
together_ai_key = os.getenv("TOGETHER_AI")
|
| 10 |
if not together_ai_key:
|
| 11 |
+
raise ValueError("TOGETHER_AI environment variable not found. Please set it before running the script.")
|
| 12 |
|
| 13 |
# Initialize Together client
|
| 14 |
client = Together(api_key=together_ai_key)
|
|
|
|
| 81 |
|
| 82 |
def rankerAgent(prompt, config_file='config.json', model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo"):
|
| 83 |
# Load API key from configuration file
|
| 84 |
+
together_ai_key = os.getenv("TOGETHER_AI")
|
|
|
|
|
|
|
|
|
|
| 85 |
if not together_ai_key:
|
| 86 |
+
raise ValueError("TOGETHER_AI environment variable not found. Please set it before running the script.")
|
| 87 |
+
|
| 88 |
|
| 89 |
# Initialize Together client
|
| 90 |
client = Together(api_key=together_ai_key)
|
|
|
|
| 129 |
|
| 130 |
return response_bestModel.choices[0].message.content, response_bestAnswer.choices[0].message.content
|
| 131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Agents/togetherAIAgent.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import json
|
| 2 |
from together import Together
|
| 3 |
|
| 4 |
def generate_article_from_query(query, config_file='config.json', model="meta-llama/Llama-3-8b-chat-hf"):
|
|
@@ -13,13 +13,11 @@ def generate_article_from_query(query, config_file='config.json', model="meta-ll
|
|
| 13 |
Returns:
|
| 14 |
- str: The generated article content.
|
| 15 |
"""
|
| 16 |
-
# Load API key from configuration file
|
| 17 |
-
with open(config_file, 'r') as file:
|
| 18 |
-
config = json.load(file)
|
| 19 |
|
| 20 |
-
together_ai_key =
|
| 21 |
if not together_ai_key:
|
| 22 |
-
raise ValueError("TOGETHER_AI
|
|
|
|
| 23 |
|
| 24 |
# Initialize Together client
|
| 25 |
client = Together(api_key=together_ai_key)
|
|
|
|
| 1 |
+
import json, os
|
| 2 |
from together import Together
|
| 3 |
|
| 4 |
def generate_article_from_query(query, config_file='config.json', model="meta-llama/Llama-3-8b-chat-hf"):
|
|
|
|
| 13 |
Returns:
|
| 14 |
- str: The generated article content.
|
| 15 |
"""
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
together_ai_key = os.getenv("TOGETHER_AI")
|
| 18 |
if not together_ai_key:
|
| 19 |
+
raise ValueError("TOGETHER_AI environment variable not found. Please set it before running the script.")
|
| 20 |
+
|
| 21 |
|
| 22 |
# Initialize Together client
|
| 23 |
client = Together(api_key=together_ai_key)
|
AnswerGeneration/getAnswer.py
CHANGED
|
@@ -3,10 +3,10 @@ import json
|
|
| 3 |
from together import Together
|
| 4 |
|
| 5 |
def generate_answer_withContext(question, context):
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
-
together_ai_key = config.get("TOGETHER_AI")
|
| 10 |
|
| 11 |
client = Together(api_key=together_ai_key)
|
| 12 |
|
|
@@ -26,10 +26,10 @@ Question: {question}
|
|
| 26 |
|
| 27 |
|
| 28 |
def generate_answer_zeroShot(question):
|
| 29 |
-
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
-
together_ai_key = config.get("TOGETHER_AI")
|
| 33 |
|
| 34 |
client = Together(api_key=together_ai_key)
|
| 35 |
|
|
|
|
| 3 |
from together import Together
|
| 4 |
|
| 5 |
def generate_answer_withContext(question, context):
|
| 6 |
+
together_ai_key = os.getenv("TOGETHER_AI")
|
| 7 |
+
if not together_ai_key:
|
| 8 |
+
raise ValueError("TOGETHER_AI environment variable not found. Please set it before running the script.")
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
client = Together(api_key=together_ai_key)
|
| 12 |
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
def generate_answer_zeroShot(question):
|
| 29 |
+
together_ai_key = os.getenv("TOGETHER_AI")
|
| 30 |
+
if not together_ai_key:
|
| 31 |
+
raise ValueError("TOGETHER_AI environment variable not found. Please set it before running the script.")
|
| 32 |
|
|
|
|
| 33 |
|
| 34 |
client = Together(api_key=together_ai_key)
|
| 35 |
|
Query_Modification/QueryModification.py
CHANGED
|
@@ -1,14 +1,13 @@
|
|
| 1 |
-
import json
|
| 2 |
import pandas as pd
|
| 3 |
import google.generativeai as genai
|
| 4 |
|
| 5 |
# Function to process text input with Gemini model
|
| 6 |
def query_Modifier(input_text):
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
gemini_key = config.get("GEMINI")
|
| 12 |
|
| 13 |
# Initialize the API key
|
| 14 |
genai.configure(api_key=gemini_key)
|
|
@@ -65,10 +64,9 @@ def query_Modifier(input_text):
|
|
| 65 |
def getKeywords(input_text):
|
| 66 |
# Extract keywords from the input text
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
gemini_key = config.get("GEMINI")
|
| 72 |
|
| 73 |
# Initialize the API key
|
| 74 |
genai.configure(api_key=gemini_key)
|
|
|
|
| 1 |
+
import json, os
|
| 2 |
import pandas as pd
|
| 3 |
import google.generativeai as genai
|
| 4 |
|
| 5 |
# Function to process text input with Gemini model
|
| 6 |
def query_Modifier(input_text):
|
| 7 |
|
| 8 |
+
gemini_key = os.getenv("GEMINI")
|
| 9 |
+
if not gemini_key:
|
| 10 |
+
raise ValueError("GEMINI environment variable not found. Please set it before running the script.")
|
|
|
|
| 11 |
|
| 12 |
# Initialize the API key
|
| 13 |
genai.configure(api_key=gemini_key)
|
|
|
|
| 64 |
def getKeywords(input_text):
|
| 65 |
# Extract keywords from the input text
|
| 66 |
|
| 67 |
+
gemini_key = os.getenv("GEMINI")
|
| 68 |
+
if not gemini_key:
|
| 69 |
+
raise ValueError("GEMINI environment variable not found. Please set it before running the script.")
|
|
|
|
| 70 |
|
| 71 |
# Initialize the API key
|
| 72 |
genai.configure(api_key=gemini_key)
|