Ferdi commited on
Commit
c72c1d8
·
1 Parent(s): d24af38
Files changed (4) hide show
  1. src/app.py +3 -9
  2. src/conversation.py +4 -4
  3. src/instructions.txt +11 -15
  4. src/vector_index.py +2 -2
src/app.py CHANGED
@@ -10,7 +10,6 @@ with gr.Blocks(gr.themes.Soft(primary_hue=gr.themes.colors.slate, secondary_hue=
10
  with gr.Row():
11
 
12
  with gr.Column(scale=1, variant = 'panel'):
13
- # gr.HTML(f"<img src='file/logo.png' width='100' height='100'>")
14
  files = gr.File(type="filepath", file_count="multiple")
15
  with gr.Row(equal_height=True):
16
  vector_index_btn = gr.Button('Create vector store', variant='primary',scale=1)
@@ -19,24 +18,19 @@ with gr.Blocks(gr.themes.Soft(primary_hue=gr.themes.colors.slate, secondary_hue=
19
  instruction = gr.Textbox(label="System instruction", lines=3, value=instruction_text)
20
 
21
  with gr.Accordion(label="Text generation tuning parameters"):
22
- temperature = gr.Slider(label="temperature", minimum=0.1, maximum=1, value=0.1, step=0.05)
23
  max_new_tokens = gr.Slider(label="max_new_tokens", minimum=1, maximum=4096, value=1024, step=1)
24
  k_context=gr.Slider(label="k_context", minimum=1, maximum=15, value=5, step=1)
25
 
26
  vector_index_btn.click(upload_and_create_vector_store, inputs=[files], outputs=vector_index_msg_out)
27
 
28
  with gr.Column(scale=1, variant = 'panel'):
29
- """
30
  with gr.Row(equal_height=True):
31
 
32
  with gr.Column(scale=1):
33
- llm = gr.Dropdown(choices= ["gpt-3.5-turbo", "gpt-3.5-turbo-instruct", "gpt-3.5-turbo-16k", "gpt-4", "gpt-4-32k"],
34
  label="Select the model")
35
 
36
- with gr.Column(scale=1):
37
- model_load_btn = gr.Button('Load model', variant='primary',scale=2)
38
- load_success_msg = gr.Textbox(show_label=False,lines=1, placeholder="Model loading ...")
39
- """
40
  with gr.Row(equal_height=True):
41
  model_load_btn = gr.Button('Load model', variant='primary',scale=2)
42
  load_success_msg = gr.Textbox(show_label=False,lines=1, placeholder="Model loading ...")
@@ -53,7 +47,7 @@ with gr.Blocks(gr.themes.Soft(primary_hue=gr.themes.colors.slate, secondary_hue=
53
  with gr.Column(scale=1):
54
  clear_btn = gr.Button('Clear',variant='stop',size = 'sm')
55
 
56
- model_load_btn.click(load_models, [],load_success_msg, api_name="load_models")
57
 
58
  txt.submit(add_text, [chatbot, txt], [chatbot, txt]).then(
59
  bot, [chatbot,instruction,temperature,max_new_tokens,k_context], chatbot)
 
10
  with gr.Row():
11
 
12
  with gr.Column(scale=1, variant = 'panel'):
 
13
  files = gr.File(type="filepath", file_count="multiple")
14
  with gr.Row(equal_height=True):
15
  vector_index_btn = gr.Button('Create vector store', variant='primary',scale=1)
 
18
  instruction = gr.Textbox(label="System instruction", lines=3, value=instruction_text)
19
 
20
  with gr.Accordion(label="Text generation tuning parameters"):
21
+ temperature = gr.Slider(label="temperature", minimum=0.1, maximum=1, value=0.8, step=0.05)
22
  max_new_tokens = gr.Slider(label="max_new_tokens", minimum=1, maximum=4096, value=1024, step=1)
23
  k_context=gr.Slider(label="k_context", minimum=1, maximum=15, value=5, step=1)
24
 
25
  vector_index_btn.click(upload_and_create_vector_store, inputs=[files], outputs=vector_index_msg_out)
26
 
27
  with gr.Column(scale=1, variant = 'panel'):
 
28
  with gr.Row(equal_height=True):
29
 
30
  with gr.Column(scale=1):
31
+ llm = gr.Dropdown(choices= ["gpt-3.5-turbo", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-1106", "gpt-4-turbo-preview", "gpt-4-0125-preview", "gpt-4-1106-preview"],
32
  label="Select the model")
33
 
 
 
 
 
34
  with gr.Row(equal_height=True):
35
  model_load_btn = gr.Button('Load model', variant='primary',scale=2)
36
  load_success_msg = gr.Textbox(show_label=False,lines=1, placeholder="Model loading ...")
 
47
  with gr.Column(scale=1):
48
  clear_btn = gr.Button('Clear',variant='stop',size = 'sm')
49
 
50
+ model_load_btn.click(load_models, [llm],load_success_msg, api_name="load_models")
51
 
52
  txt.submit(add_text, [chatbot, txt], [chatbot, txt]).then(
53
  bot, [chatbot,instruction,temperature,max_new_tokens,k_context], chatbot)
src/conversation.py CHANGED
@@ -7,21 +7,21 @@ from langchain_community.embeddings import HuggingFaceEmbeddings
7
  import os
8
 
9
  openai_api_key = os.environ.get("OPENAI_API_KEY")
10
- model_name = os.environ.get('MODEL_NAME', 'all-MiniLM-L6-v2')
11
  pinecone_index = os.environ.get("PINECONE_INDEX")
12
 
13
  class Conversation_RAG:
14
- def __init__(self, model_name="gpt-3.5-turbo"):
15
  self.model_name = model_name
16
 
17
  def get_vectordb(self, pc):
18
  index = pc.Index(pinecone_index)
19
- embeddings = HuggingFaceEmbeddings(model_name=f"./model/{model_name}")
20
  vectordb = Pinecone(index, embeddings, "text")
21
 
22
  return vectordb
23
 
24
- def create_model(self, max_new_tokens=512, temperature=0.1):
25
  llm = ChatOpenAI(
26
  openai_api_key=openai_api_key,
27
  model_name=self.model_name,
 
7
  import os
8
 
9
  openai_api_key = os.environ.get("OPENAI_API_KEY")
10
+ model_name = os.environ.get('MODEL_NAME', 'all-mpnet-base-v2')
11
  pinecone_index = os.environ.get("PINECONE_INDEX")
12
 
13
  class Conversation_RAG:
14
+ def __init__(self, model_name="gpt-3.5-turbo-instruct"):
15
  self.model_name = model_name
16
 
17
  def get_vectordb(self, pc):
18
  index = pc.Index(pinecone_index)
19
+ embeddings = HuggingFaceEmbeddings(model_name=f"model/{model_name}")
20
  vectordb = Pinecone(index, embeddings, "text")
21
 
22
  return vectordb
23
 
24
+ def create_model(self, max_new_tokens=512, temperature=0.8):
25
  llm = ChatOpenAI(
26
  openai_api_key=openai_api_key,
27
  model_name=self.model_name,
src/instructions.txt CHANGED
@@ -1,18 +1,14 @@
1
- Using the detailed context provided and the specific input regarding the client's case, follow these instructions to assist in drafting a petition related to French employment law.
2
 
3
- 1. **Client Case Input**: {input}
4
 
5
- 2. **Document Context Input**: {context}
 
 
 
 
 
 
6
 
7
- Given the context and input, perform the following steps:
8
-
9
- - Understand the specifics of the client's case and the context provided by the retrieved documents.
10
- - Analyze the legal framework and precedents to identify applicable legal principles and arguments that can support the client's position.
11
- - Generate a draft petition that includes:
12
- - A tailored statement of facts based on the client's input.
13
- - A presentation of legal issues informed by the document context.
14
- - A compelling argumentation section that leverages insights from the document context.
15
- - A conclusion outlining the desired remedies or relief, in accordance with French employment law.
16
-
17
- Ensure the draft is coherent, precise, and aligned with current legal standards and practices, maintaining confidentiality and adapting the content to the unique aspects of the client's case.
18
- Please note that the entire draft, including legal arguments and factual descriptions, should be prepared in French to comply with the requirements of the French legal system.
 
1
+ En utilisant le contexte détaillé fourni et les données spécifiques concernant le cas du client, suivez les instructions suivantes pour vous aider à rédiger une pétition relative au droit du travail français.
2
 
3
+ Compte tenu du contexte et des informations fournies, procédez comme suit :
4
 
5
+ - Comprendre les spécificités du cas du client et le contexte fourni par les documents récupérés.
6
+ - Analyser le cadre juridique et les précédents afin d'identifier les principes juridiques applicables et les arguments susceptibles d'étayer la position du client.
7
+ - Rédiger un projet de requête comprenant
8
+ - Un exposé des faits adapté, basé sur les informations fournies par le client.
9
+ - Une présentation des questions juridiques éclairée par le contexte du document.
10
+ - Une section d'argumentation convaincante qui exploite les informations tirées du contexte du document.
11
+ - Une conclusion décrivant les mesures correctives ou de redressement souhaitées, conformément au droit du travail français.
12
 
13
+ Veiller à ce que le projet soit cohérent, précis et conforme aux normes et pratiques juridiques actuelles, tout en préservant la confidentialité et en adaptant le contenu aux aspects uniques du cas du client.
14
+ IMPORTANT : L'ensemble du projet, y compris les arguments juridiques et les descriptions factuelles, doit être rédigé en langue française afin de respecter les exigences du système juridique français.
 
 
 
 
 
 
 
 
 
 
src/vector_index.py CHANGED
@@ -4,7 +4,7 @@ from langchain.text_splitter import RecursiveCharacterTextSplitter
4
  from langchain_community.embeddings import HuggingFaceEmbeddings
5
  import os, uuid
6
 
7
- model_name = os.environ.get('MODEL_NAME', 'all-MiniLM-L6-v2')
8
 
9
  def create_vector_store_index(file_path):
10
 
@@ -31,7 +31,7 @@ def create_vector_store_index(file_path):
31
 
32
  index = pc.Index(os.environ.get("PINECONE_INDEX"))
33
 
34
- embeddings = HuggingFaceEmbeddings(model_name=f"./model/{model_name}")
35
 
36
  batch_size = 32
37
 
 
4
  from langchain_community.embeddings import HuggingFaceEmbeddings
5
  import os, uuid
6
 
7
+ model_name = os.environ.get('MODEL_NAME', 'all-mpnet-base-v2')
8
 
9
  def create_vector_store_index(file_path):
10
 
 
31
 
32
  index = pc.Index(os.environ.get("PINECONE_INDEX"))
33
 
34
+ embeddings = HuggingFaceEmbeddings(model_name=f"model/{model_name}")
35
 
36
  batch_size = 32
37