This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from loyal812/feat/chatting-class
feat: chatting class
- Loading branch information
Showing
22 changed files
with
125 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,6 @@ llama_index==0.9.15 | |
pypdf | ||
spacy | ||
ragas | ||
datasets | ||
datasets | ||
docx2txt | ||
cryptography |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import openai | ||
import os | ||
import argparse | ||
from dotenv import load_dotenv | ||
from llama_index import ServiceContext, SimpleDirectoryReader, VectorStoreIndex | ||
from llama_index.llms import OpenAI | ||
|
||
class ChattingClass: | ||
def __init__(self, model_id, data_path, api_key="", temperature=0.3): | ||
self.model_id = model_id | ||
self.data_path = data_path | ||
self.temperature = temperature | ||
self.set_api_key(api_key) | ||
self.set_document(data_path) | ||
|
||
def set_api_key(self, api_key): | ||
if api_key: | ||
self.api_key = api_key | ||
else: | ||
load_dotenv() | ||
self.api_key = os.getenv("OPENAI_API_KEY") | ||
|
||
if self.api_key is not None: | ||
os.environ["OPENAI_API_KEY"] = self.api_key | ||
openai.api_key = self.api_key | ||
return True | ||
else: | ||
# Handle the absence of the environment variable | ||
# You might want to log an error, raise an exception, or provide a default value | ||
# For example, setting a default value | ||
os.environ["OPENAI_API_KEY"] = "your_default_api_key" | ||
openai.api_key = "openai_api_key" | ||
return False | ||
|
||
def set_document(self, data_path): | ||
self.documents = SimpleDirectoryReader( | ||
data_path | ||
).load_data() | ||
|
||
def ask_question(self, question): | ||
ft_context = ServiceContext.from_defaults( | ||
llm=OpenAI(model=self.model_id, temperature=self.temperature), | ||
context_window=2048 | ||
) | ||
|
||
index = VectorStoreIndex.from_documents(self.documents, service_context=ft_context) | ||
query_engine = index.as_query_engine(service_context=ft_context) | ||
|
||
response = query_engine.query(question) | ||
return response | ||
|
||
# Using argparse to get the question input from the user | ||
parser = argparse.ArgumentParser(description='Chatting Engine') | ||
# parser.add_argument('api_key', type=str, help='Openai API Key') | ||
parser.add_argument('data_path', type=str, help='Data Path') | ||
parser.add_argument('model_id', type=str, help='model') | ||
parser.add_argument('question', type=str, help='question') | ||
# parser.add_argument('temperature', type=str, help='temperature') | ||
args = parser.parse_args() | ||
|
||
# model_id = 'ft:gpt-3.5-turbo-0613:personal::8XaasBXv' | ||
# data_path = "./src/test/regression/regression_test003" | ||
chatbot = ChattingClass(model_id=args.model_id, data_path=args.data_path) | ||
|
||
response = chatbot.ask_question(args.question) | ||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Binary file not shown.
Binary file not shown.
Empty file.
11 changes: 11 additions & 0 deletions
11
src/test/regression/regression_test003/generated_data/eval_questions.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
What is the correlation between the distance in the latent space and the MPJPE in the AI Golf swing analysis tool? | ||
What is the title of the paper mentioned in the context? | ||
What is the title of the paper mentioned in the context? | ||
Question: What is the title of the paper referenced in citation [28]? | ||
Question: Who received the B.S. degree from the School of Computer Science and Engineering, Korea University of Technology and Education, Cheonan, South Korea, in 2017? | ||
Question: What method was used to remove the background pixels and isolate the human body in the video dataset? | ||
What evaluation metric was used to assess the alignment precision of the network in the golf swing analysis tool? | ||
What is the main challenge addressed in the proposed golf swing analysis tool using neural networks? | ||
What recent advancements in technology have allowed for the development of systems to help users understand the movements of professionals in sports? | ||
What are the main contributions of the study on the golf swing analysis tool for self-training? | ||
What is one of the main contributions of the proposed golf swing analysis method discussed in the study? |
Oops, something went wrong.