Skip to content

Commit

Permalink
fix: llm issue
Browse files Browse the repository at this point in the history
  • Loading branch information
NingLu committed Apr 11, 2024
1 parent 5d49b67 commit 90f8d58
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 52 deletions.
105 changes: 60 additions & 45 deletions source/lambda/executor/utils/llm_utils/llm_chains/__init__.py
Original file line number Diff line number Diff line change
@@ -1,75 +1,90 @@
from .llm_chain_base import LLMChain
from .chat_chain import (
Baichuan2Chat13B4BitsChatChain,
Claude2ChatChain,
Claude3HaikuChatChain,
Claude3SonnetChatChain,
Claude21ChatChain,
ClaudeInstanceChatChain,
Iternlm2Chat7BChatChain,
Iternlm2Chat20BChatChain,
Baichuan2Chat13B4BitsChatChain,
Claude3HaikuChatChain,
Claude3SonnetChatChain
)

from .conversation_summary_chain import (
Iternlm2Chat7BConversationSummaryChain,
ClaudeInstanceConversationSummaryChain,
Claude21ConversationSummaryChain,
Claude3HaikuConversationSummaryChain,
Claude3SonnetConversationSummaryChain,
Claude21ConversationSummaryChain,
ClaudeInstanceConversationSummaryChain,
Iternlm2Chat7BConversationSummaryChain,
Iternlm2Chat20BConversationSummaryChain,
)
from .hyde_chain import (
Claude2HydeChain,
Claude3HaikuHydeChain,
Claude3SonnetHydeChain,
Claude21HydeChain,
ClaudeInstanceHydeChain,
Iternlm2Chat7BHydeChain,
Iternlm2Chat20BHydeChain,
Iternlm2Chat20BConversationSummaryChain
)

from .intention_chain import (
Claude21IntentRecognitionChain,
Claude2IntentRecognitionChain,
ClaudeInstanceIntentRecognitionChain,
Claude3HaikuIntentRecognitionChain,
Claude3SonnetIntentRecognitionChain,
Claude21IntentRecognitionChain,
ClaudeInstanceIntentRecognitionChain,
Iternlm2Chat7BIntentRecognitionChain,
Iternlm2Chat20BIntentRecognitionChain,

)
from .llm_chain_base import LLMChain
from .mkt_conversation_summary import (
Claude2MKTConversationSummaryChain,
Claude3HaikuMKTConversationSummaryChain,
Claude3SonnetMKTConversationSummaryChain,
Claude21MKTConversationSummaryChain,
ClaudeInstanceMKTConversationSummaryChain,
Iternlm2Chat7BMKTConversationSummaryChain,
Iternlm2Chat20BMKTConversationSummaryChain,
)
from .query_rewrite_chain import (
Claude2QueryRewriteChain,
Claude3HaikuQueryRewriteChain,
Claude3SonnetQueryRewriteChain,
Claude21QueryRewriteChain,
ClaudeInstanceQueryRewriteChain,
Iternlm2Chat7BQueryRewriteChain,
Iternlm2Chat20BQueryRewriteChain,
)

from .rag_chain import (
Baichuan2Chat13B4BitsKnowledgeQaChain,
Claude21RagLLMChain,
Claude2RagLLMChain,
ClaudeInstanceRAGLLMChain,
Claude3HaikuRAGLLMChain,
Claude3SonnetRAGLLMChain,
Claude21RagLLMChain,
ClaudeInstanceRAGLLMChain,
Baichuan2Chat13B4BitsKnowledgeQaChain,
Iternlm2Chat7BKnowledgeQaChain,
Iternlm2Chat20BKnowledgeQaChain,
Iternlm2Chat20BKnowledgeQaChain
)


from .translate_chain import (
Iternlm2Chat7BTranslateChain,
Iternlm2Chat20BTranslateChain
)


from .mkt_conversation_summary import (
Claude21MKTConversationSummaryChain,
ClaudeInstanceMKTConversationSummaryChain,
Claude2MKTConversationSummaryChain,
Claude3HaikuMKTConversationSummaryChain,
Claude3SonnetMKTConversationSummaryChain,
Iternlm2Chat7BMKTConversationSummaryChain,
Iternlm2Chat20BMKTConversationSummaryChain
)

from .stepback_chain import (
Claude21StepBackChain,
ClaudeInstanceStepBackChain,
Claude2StepBackChain,
Claude3HaikuStepBackChain,
Claude3SonnetStepBackChain,
Claude21StepBackChain,
ClaudeInstanceStepBackChain,
Iternlm2Chat7BStepBackChain,
Iternlm2Chat20BStepBackChain,
Iternlm2Chat20BStepBackChain
)


from .hyde_chain import (
Claude21HydeChain,
Claude2HydeChain,
Claude3HaikuHydeChain,
Claude3SonnetHydeChain,
ClaudeInstanceHydeChain,
Iternlm2Chat20BHydeChain,
Iternlm2Chat7BHydeChain
)

from .query_rewrite_chain import (
Claude21QueryRewriteChain,
Claude2QueryRewriteChain,
ClaudeInstanceQueryRewriteChain,
Claude3HaikuQueryRewriteChain,
Claude3SonnetQueryRewriteChain,
Iternlm2Chat20BQueryRewriteChain,
Iternlm2Chat7BQueryRewriteChain
)
from .translate_chain import Iternlm2Chat7BTranslateChain, Iternlm2Chat20BTranslateChain
4 changes: 2 additions & 2 deletions source/panel/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def pipeline_tab():
job_runs_container += (f" Duration: {job_run.get('ExecutionTime', 'N/A')} seconds\n")
st.text_area('Running AWS Glue Jobs in total: ' + str(total_job_runs), value=job_runs_container, height=200, max_chars=None)

# sub pannel to query and search the embedding in AOS
# Sub panel to query and search the embedding in AOS
st.subheader('Query and Search AOS')
query = st.text_input('Input your query body here', value='{"aos_index": "chatbot-index", "query": {"operation": "match_all", "match_all": {}}}')
# send button to trigger the request sending to the endpoint with query as request body
Expand Down Expand Up @@ -203,7 +203,7 @@ def main():
elif page == "LLM Bot":
llm_bot_tab()

# using libary and OpenAI for local testing, comment for now
# using library and OpenAI for local testing, comment for now

# if pdf is not None:
# pdf_reader = PdfReader(pdf)
Expand Down
2 changes: 1 addition & 1 deletion source/panel/evaluator/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Excute the following commands to setup local Amazon Open Search running on docker.
Execute the following commands to setup local Amazon Open Search running on docker.
'''
docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" opensearchproject/opensearch:latest
'''
Expand Down
6 changes: 3 additions & 3 deletions source/panel/evaluator/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def run_evaluation(chain, retriever, eval_set, grade_prompt, retriever_type, num
start_time = time.time()

# Get docs
if retriever_type == "Faiss retriver":
if retriever_type == "Faiss retriever":
docs = retriever.similarity_search(query=data["question"],k=num_neighbors,filter=metadata_filter)
elif retriever_type == "CSDC retriever":
docs = retriever.similarity_search(query=data["question"],k=num_neighbors,filter=metadata_filter)
Expand Down Expand Up @@ -231,7 +231,7 @@ def run_evaluation(chain, retriever, eval_set, grade_prompt, retriever_type, num
index=1)

retriever_type = st.radio("`Choose retriever`",
("Faiss retriver",
("Faiss retriever",
"CSDC retriever",),
index=0)

Expand Down Expand Up @@ -288,7 +288,7 @@ def run_evaluation(chain, retriever, eval_set, grade_prompt, retriever_type, num
# Make LLM
llm = make_llm(model)

# Make retriver
# Make retriever
retriever = make_retriever(retriever_type,embeddings)

# Make chain
Expand Down
2 changes: 1 addition & 1 deletion source/sample/script/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ aws ec2 describe-key-pairs --query 'KeyPairs[*].{Name:KeyName}' --output text
aws ec2 run-instances --image-id ami-01cb61d12413ba783 --count 1 --instance-type t2.micro --key-name us-west-2 --security-group-ids sg-0ceb6e950b89e8f69 --subnet-id subnet-b42915ff --user-data file://nginx.sh --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=ec2Endpoint}]' --query 'Instances[*].{ID:InstanceId,IP:PublicIpAddress}' --output text
```

## 2.2. lanuch the flask app
## 2.2. launch the flask app

```bash
export FLASK_APP=app.py # Replace 'app.py' with the name of your Flask app file if it's different
Expand Down

0 comments on commit 90f8d58

Please sign in to comment.