Somekindofa commited on
Commit
d7c5e54
·
1 Parent(s): a649f7b

bug/retry CoT

Browse files
Files changed (1) hide show
  1. app.py +947 -241
app.py CHANGED
@@ -1,184 +1,931 @@
1
  import gradio as gr
2
  import spaces
3
  from huggingface_hub import login
 
 
 
4
  import torch
 
5
  from threading import Thread
6
- from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
7
- import os
8
- from typing import Iterator, List, Dict, Any
9
 
10
  # Initialize logging and device information
11
  print(f"Is CUDA available: {torch.cuda.is_available()}")
12
  print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
13
 
14
  MAX_MAX_NEW_TOKENS = 14000
15
- DEFAULT_MAX_NEW_TOKENS = int(0.65 * MAX_MAX_NEW_TOKENS)
 
16
  MAX_INPUT_TOKEN_LENGTH = 100000
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- # Enhanced system prompt for chain-of-thought reasoning
19
- DEFAULT_SYSTEM_PROMPT = """Tu réponds à la question de l'utilisateur.
20
- Pour créer une ontologie précise, suis ces étapes de raisonnement:
21
- 1. Identifie les entités principales dans le texte
22
- 2. Détermine les relations entre ces entités
23
- 3. Organise hiérarchiquement les concepts
24
- 4. Formalise en utilisant la structure RDF/Turtle appropriée
25
 
26
- Raisonne étape par étape, en expliquant ton processus, avant de donner ta réponse finale.
27
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  class HuggingFaceLogin:
30
  """Handles authentication to the Hugging Face Hub using environment variables or explicit tokens."""
31
  def __init__(self, env_token_key: str = "HF_TOKEN"):
32
- """Initialize the login handler."""
 
 
 
 
33
  self.token = os.getenv(env_token_key)
34
 
35
  def login(self, token: str = None) -> bool:
36
- """Authenticate with the Hugging Face Hub."""
37
- if not self.token and not token:
 
 
 
 
 
 
 
 
 
 
 
38
  raise ValueError("No authentication token provided. Set HF_TOKEN environment variable or pass token explicitly.")
39
  try:
40
  print("Logging in to the Hugging Face Hub...")
41
- login(token=token or self.token)
42
  return True
43
  except Exception as e:
44
  print(f"Login failed: {str(e)}")
45
  return False
46
 
47
- def append_text_knowledge(file_path: str) -> str:
48
- """Reads content from a selected file and returns it as a string."""
49
- if file_path:
50
- try:
51
- with open(file_path, "r", encoding="utf-8") as f:
52
- return f.read()
53
- except Exception as e:
54
- print(f"Error reading file: {e}")
55
- return ""
56
- return ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  @spaces.GPU
59
- def generate_with_thinking(
60
  message: str,
61
- chat_history: List[Dict],
62
- knowledge: str,
63
  system_prompt: str = DEFAULT_SYSTEM_PROMPT,
64
- max_new_tokens: int = DEFAULT_MAX_NEW_TOKENS,
65
- temperature: float = 0.2, # Lower temperature for more deterministic reasoning
66
  top_p: float = 0.8,
67
  top_k: int = 50,
68
- repetition_penalty: float = 1.0 # Reduced for consistent reasoning
69
- ) -> Iterator[List[Dict]]:
70
- """Generate responses with visible chain-of-thought reasoning."""
71
-
72
- # Format chat history for use with model
73
- formatted_history = []
74
-
75
- # Add user message to chat history for display
76
- chat_history.append({"role": "user", "content": message})
77
- current_history = chat_history.copy()
78
-
79
- # Add thinking message with pending status
80
- thinking_message = {
81
- "role": "assistant",
82
- "content": "Je réfléchis étape par étape...",
83
- "metadata": {
84
- "title": "🧠 Réflexion",
85
- "status": "pending"
86
- }
87
- }
88
- current_history.append(thinking_message)
89
-
90
- # Return initial state with thinking message
91
- yield current_history
92
-
93
  try:
94
- # Build conversation for the model
95
- model_conversation = []
96
  if system_prompt:
97
- model_conversation.append({"role": "system", "content": system_prompt})
98
-
99
- # Add knowledge context if available
100
  if knowledge:
101
- model_conversation.append({
102
- "role": "assistant",
103
- "content": f"Voici le texte existant que je dois comprendre: {knowledge}\n\nJe vais l'analyser étape par étape."
104
- })
105
-
106
- # Add previous messages from history
107
- for msg in chat_history[:-1]: # Exclude the latest user message which we'll add with thinking prompt
108
- formatted_history.append(msg)
109
- model_conversation.append(msg)
110
-
111
- # Add current message with thinking prompt
112
  thinking_prompt = message + "\n\nRéfléchis étape par étape. Identifie d'abord les entités, puis les relations, puis organise hiérarchiquement avant de formaliser."
113
- model_conversation.append({"role": "user", "content": thinking_prompt})
114
-
115
- # Generate thinking content
 
 
 
 
 
116
  thinking_result = generate_llm_response(
117
- model_conversation,
118
- max_new_tokens=max_new_tokens * 2, # More tokens for thinking
119
  temperature=temperature,
120
  top_p=top_p,
121
  top_k=top_k,
122
  repetition_penalty=repetition_penalty
123
  )
 
 
 
 
 
124
 
125
- # Update thinking message with result and mark as complete
126
- thinking_message["content"] = thinking_result
127
- thinking_message["metadata"]["status"] = "done"
128
- current_history[-1] = thinking_message
129
-
130
- # Return updated chat history with thinking result
131
- yield current_history
132
-
133
- # Build conversation for final response
134
  final_conversation = []
135
- if system_prompt:
136
- final_conversation.append({"role": "system", "content": system_prompt})
137
-
138
  if knowledge:
139
- final_conversation.append({"role": "assistant", "content": f"J'ai analysé cette ontologie: {knowledge}"})
 
 
140
 
141
- # Add previous messages
142
- for msg in chat_history[:-1]:
143
- final_conversation.append(msg)
144
-
145
- # Add current message and thinking reference
146
- final_conversation.append({"role": "user", "content": message})
147
- final_conversation.append({
148
- "role": "assistant",
149
- "content": f"Voici mon analyse étape par étape:\n{thinking_result}\n\nMaintenant, je vais formaliser le résultat final."
150
- })
151
-
152
- # Generate final answer
153
  final_answer = generate_llm_response(
154
  final_conversation,
155
  max_new_tokens=max_new_tokens,
156
- temperature=temperature * 0.8, # Even lower temperature for final response
157
  top_p=top_p,
158
  top_k=top_k,
159
  repetition_penalty=repetition_penalty
160
  )
161
-
162
- # Add final answer to chat history
163
- current_history.append({
164
  "role": "assistant",
165
  "content": final_answer
166
- })
167
-
168
- # Return final chat history with both thinking and answer
169
- yield current_history
170
-
171
  except Exception as e:
172
- # Handle errors gracefully
173
- error_message = f"An error occurred: {str(e)}"
174
- current_history.append({
175
  "role": "assistant",
176
- "content": error_message
177
- })
178
- yield current_history
179
-
180
  def generate_llm_response(
181
- conversation: List[Dict],
182
  max_new_tokens: int,
183
  temperature: float,
184
  top_p: float,
@@ -186,9 +933,6 @@ def generate_llm_response(
186
  repetition_penalty: float
187
  ) -> str:
188
  """Generate a response from the LLM based on the conversation."""
189
- # Access global model and tokenizer
190
- global model, tokenizer
191
-
192
  input_ids = tokenizer.apply_chat_template(
193
  conversation,
194
  return_tensors="pt",
@@ -217,7 +961,10 @@ def generate_llm_response(
217
  pad_token_id=tokenizer.eos_token_id,
218
  )
219
 
220
- t = Thread(target=model.generate, kwargs=generate_kwargs)
 
 
 
221
  t.start()
222
 
223
  # Collect the output
@@ -227,134 +974,93 @@ def generate_llm_response(
227
 
228
  return "".join(outputs)
229
 
230
- # Main application setup
231
- if torch.cuda.is_available():
232
- model_id = "meta-llama/Llama-3.1-8B-Instruct"
233
- model = AutoModelForCausalLM.from_pretrained(
234
- model_id,
235
- load_in_8bit=True,
236
- device_map="auto"
237
- )
238
- tokenizer = AutoTokenizer.from_pretrained(model_id)
239
 
240
- # UI components
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  knowledge_textbox = gr.Textbox(
242
  label="Knowledge Text",
243
- lines=20,
244
  visible=False
245
  )
246
 
247
- # Create the chat interface
248
- with gr.Blocks() as demo:
249
- gr.Markdown("# Ontology Generation with Chain-of-Thought")
250
-
251
- chatbot = gr.Chatbot(
252
- type="messages", # Essential for ChatMessage support
253
- show_label=True,
254
- label="Llama 3.1 with Chain-of-Thought",
255
- height=600
256
- )
257
-
258
- with gr.Row():
259
- file_explorer = gr.FileExplorer(
260
- glob="**/*.txt",
261
- file_count="single",
262
- label="Upload an elicitation file",
263
- show_label=True
264
- )
265
- knowledge_input = knowledge_textbox
266
-
267
- with gr.Row():
268
- message_input = gr.Textbox(
269
- label="Message",
270
- placeholder="Ask about or request ontology generation...",
271
- lines=2
272
- )
273
-
274
- with gr.Accordion("Advanced Settings", open=False):
275
- system_prompt_input = gr.Textbox(
276
- label="System prompt",
277
- lines=6,
278
- value=DEFAULT_SYSTEM_PROMPT
279
- )
280
-
281
- with gr.Row():
282
- with gr.Column():
283
- max_tokens_slider = gr.Slider(
284
- label="Max new tokens",
285
- minimum=1,
286
- maximum=MAX_MAX_NEW_TOKENS,
287
- step=1,
288
- value=DEFAULT_MAX_NEW_TOKENS,
289
- )
290
- temperature_slider = gr.Slider(
291
- label="Temperature",
292
- minimum=0.1,
293
- maximum=4.0,
294
- step=0.1,
295
- value=0.2,
296
- )
297
-
298
- with gr.Column():
299
- top_p_slider = gr.Slider(
300
- label="Top-p (nucleus sampling)",
301
- minimum=0.05,
302
- maximum=1.0,
303
- step=0.05,
304
- value=0.8,
305
- )
306
- top_k_slider = gr.Slider(
307
- label="Top-k",
308
- minimum=1,
309
- maximum=1000,
310
- step=1,
311
- value=50,
312
- )
313
- repetition_penalty_slider = gr.Slider(
314
- label="Repetition penalty",
315
- minimum=1.0,
316
- maximum=2.0,
317
- step=0.05,
318
- value=1.0,
319
- )
320
-
321
- # Examples showcase
322
- examples = gr.Examples(
323
- examples=[
324
- ["In bullet-points, give me the classes from that Turtle ontology :"],
325
- ["Extract the properties from the ontology and organize them by domain"],
326
- ["Create a new ontology for describing a manufacturing process based on the existing ontology"],
327
  ],
328
- inputs=message_input
 
 
 
329
  )
330
-
331
- # Setup event handlers
332
- file_explorer.change(append_text_knowledge, file_explorer, knowledge_input)
333
-
334
- # Submit message event
335
- message_input.submit(
336
- generate_with_thinking,
337
- inputs=[
338
- message_input,
339
- chatbot,
340
- knowledge_input,
341
- system_prompt_input,
342
- max_tokens_slider,
343
- temperature_slider,
344
- top_p_slider,
345
- top_k_slider,
346
- repetition_penalty_slider
347
- ],
348
- outputs=chatbot
349
- ).then(
350
- lambda: "", # Clear input box after sending
351
- None,
352
- message_input
353
  )
 
 
354
 
355
- # Launch the app
356
  if __name__ == "__main__":
357
  auth = HuggingFaceLogin()
358
  if auth.login():
359
  print("Login successful!")
360
- demo.queue().launch()
 
1
  import gradio as gr
2
  import spaces
3
  from huggingface_hub import login
4
+ import accelerate
5
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TextIteratorStreamer
6
+ import os
7
  import torch
8
+ from typing import Optional, Iterator, Dict, Any, List
9
  from threading import Thread
10
+ from types import NoneType
11
+
 
12
 
13
  # Initialize logging and device information
14
  print(f"Is CUDA available: {torch.cuda.is_available()}")
15
  print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
16
 
17
  MAX_MAX_NEW_TOKENS = 14000
18
+ DEFAULT_MAX_NEW_TOKENS = 0.65*MAX_MAX_NEW_TOKENS
19
+ # MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))
20
  MAX_INPUT_TOKEN_LENGTH = 100000
21
+ DEFAULT_USER_QUERY = '''
22
+ @prefix : <urn:webprotege:ontology:7272b2af-011f-4d40-8519-9fc3f830442e#> .
23
+ @prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
24
+ @prefix org: <http://www.w3.org/ns/org#> .
25
+ @prefix owl: <http://www.w3.org/2002/07/owl#> .
26
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
27
+ @prefix xml: <http://www.w3.org/XML/1998/namespace> .
28
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
29
+ @prefix foaf: <http://xmlns.com/foaf/spec/> .
30
+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
31
+ @prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
32
+ @prefix saref4inma: <https://saref.etsi.org/saref4inma/v1.1.2/> .
33
+ @base <urn:webprotege:ontology:7272b2af-011f-4d40-8519-9fc3f830442e> .
34
+
35
+ <urn:webprotege:ontology:7272b2af-011f-4d40-8519-9fc3f830442e> rdf:type owl:Ontology .
36
+
37
+ #################################################################
38
+ # Object Properties
39
+ #################################################################
40
+
41
+ ### http://webprotege.stanford.edu/R7Jh9tx0lYgi0o872q8BVOt
42
+ <http://webprotege.stanford.edu/R7Jh9tx0lYgi0o872q8BVOt> rdf:type owl:ObjectProperty ;
43
+ rdfs:subPropertyOf owl:topObjectProperty ;
44
+ rdfs:label "hasPersonRelation"@en .
45
+
46
+
47
+ ### http://webprotege.stanford.edu/R7xG5Hzpc2tMDfePE5rvRfO
48
+ <http://webprotege.stanford.edu/R7xG5Hzpc2tMDfePE5rvRfO> rdf:type owl:ObjectProperty ;
49
+ rdfs:subPropertyOf owl:topObjectProperty ;
50
+ rdfs:label "hasEquipmentRelation"@en .
51
+
52
+
53
+ ### http://webprotege.stanford.edu/R7zhi5KW3Sf0iZ5FGoRs9ZS
54
+ <http://webprotege.stanford.edu/R7zhi5KW3Sf0iZ5FGoRs9ZS> rdf:type owl:ObjectProperty ;
55
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R7xG5Hzpc2tMDfePE5rvRfO> ;
56
+ rdfs:domain <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
57
+ rdfs:label "usesTool"^^xsd:string .
58
+
59
+
60
+ ### http://webprotege.stanford.edu/R8M7gI8ZNRGhNMRWtqYzu37
61
+ <http://webprotege.stanford.edu/R8M7gI8ZNRGhNMRWtqYzu37> rdf:type owl:ObjectProperty ;
62
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R7Jh9tx0lYgi0o872q8BVOt> ;
63
+ rdfs:domain <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
64
+ rdfs:range <http://webprotege.stanford.edu/REFofozMBUvB1ZSMYI7UP2> ;
65
+ rdfs:label "performedBy"@en .
66
+
67
+
68
+ ### http://webprotege.stanford.edu/R8wXto8dUCR4ArFRp65XAcZ
69
+ <http://webprotege.stanford.edu/R8wXto8dUCR4ArFRp65XAcZ> rdf:type owl:ObjectProperty ;
70
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R7Jh9tx0lYgi0o872q8BVOt> ;
71
+ rdfs:domain <http://webprotege.stanford.edu/REFofozMBUvB1ZSMYI7UP2> ;
72
+ rdfs:range <http://webprotege.stanford.edu/REFofozMBUvB1ZSMYI7UP2> ;
73
+ rdfs:label "supervises"@en .
74
+
75
+
76
+ ### http://webprotege.stanford.edu/R9M5QXSk6JX8xPwwkHCe3TP
77
+ <http://webprotege.stanford.edu/R9M5QXSk6JX8xPwwkHCe3TP> rdf:type owl:ObjectProperty ;
78
+ rdfs:subPropertyOf owl:topObjectProperty ;
79
+ rdfs:label "hasMotionRelation"@en .
80
+
81
+
82
+ ### http://webprotege.stanford.edu/R9r3ozDqhU9Sg2dPMza0Nxo
83
+ <http://webprotege.stanford.edu/R9r3ozDqhU9Sg2dPMza0Nxo> rdf:type owl:ObjectProperty ;
84
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/RWMnPgTX0wus5fPS3GPw0C> ;
85
+ rdfs:domain <http://webprotege.stanford.edu/R29Nj9RpZQbHCZozi57WHL> ,
86
+ <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
87
+ rdfs:range <http://webprotege.stanford.edu/Re2wKa5UQ9OcyzVPnqXZDn> ;
88
+ rdfs:label "locatedAt"@en .
89
+
90
+
91
+ ### http://webprotege.stanford.edu/RBluTLfd3nzVTlWr7mbFCsQ
92
+ <http://webprotege.stanford.edu/RBluTLfd3nzVTlWr7mbFCsQ> rdf:type owl:ObjectProperty ;
93
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R9M5QXSk6JX8xPwwkHCe3TP> ;
94
+ rdfs:domain <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
95
+ rdfs:range <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
96
+ rdfs:label "isPartOf"^^xsd:string .
97
+
98
+
99
+ ### http://webprotege.stanford.edu/RDz5N0JgmIrvNfIyKYjI8vF
100
+ <http://webprotege.stanford.edu/RDz5N0JgmIrvNfIyKYjI8vF> rdf:type owl:ObjectProperty ;
101
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/RWMnPgTX0wus5fPS3GPw0C> ;
102
+ rdfs:domain <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
103
+ rdfs:range <http://webprotege.stanford.edu/RLFwu7zVX2LXbEjquykigV> ;
104
+ rdfs:label "hasEnvironment"@en .
105
+
106
+
107
+ ### http://webprotege.stanford.edu/RFV5p1CgBxXlnEUcbUax3N
108
+ <http://webprotege.stanford.edu/RFV5p1CgBxXlnEUcbUax3N> rdf:type owl:ObjectProperty ;
109
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R7xG5Hzpc2tMDfePE5rvRfO> ;
110
+ rdfs:domain <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
111
+ rdfs:range <http://webprotege.stanford.edu/R7a9qBHcfkQU5JnmS1cycLd> ;
112
+ rdfs:label "usesMachinery"@en .
113
+
114
+
115
+ ### http://webprotege.stanford.edu/RWMnPgTX0wus5fPS3GPw0C
116
+ <http://webprotege.stanford.edu/RWMnPgTX0wus5fPS3GPw0C> rdf:type owl:ObjectProperty ;
117
+ rdfs:subPropertyOf owl:topObjectProperty ;
118
+ rdfs:label "hasLocationRelation"@en .
119
+
120
+
121
+ ### http://webprotege.stanford.edu/RdQdw0MHlnqw7xSE3zPO8o
122
+ <http://webprotege.stanford.edu/RdQdw0MHlnqw7xSE3zPO8o> rdf:type owl:ObjectProperty ;
123
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R7xG5Hzpc2tMDfePE5rvRfO> ;
124
+ rdfs:domain <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
125
+ rdfs:range <http://webprotege.stanford.edu/RfraaLiY680VndQTbnJuxA> ;
126
+ rdfs:label "usesSafetyGear"@en .
127
+
128
+
129
+ ### http://webprotege.stanford.edu/ReZNJFnnJ7ysYKQLS6umeR
130
+ <http://webprotege.stanford.edu/ReZNJFnnJ7ysYKQLS6umeR> rdf:type owl:ObjectProperty ;
131
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R9M5QXSk6JX8xPwwkHCe3TP> ;
132
+ rdfs:domain <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
133
+ rdfs:range <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
134
+ rdfs:label "hasSubMotion"^^xsd:string .
135
+
136
+
137
+ #################################################################
138
+ # Data properties
139
+ #################################################################
140
+
141
+ ### http://webprotege.stanford.edu/R7AWo0hVldNzo1KBkKltoq6
142
+ <http://webprotege.stanford.edu/R7AWo0hVldNzo1KBkKltoq6> rdf:type owl:DatatypeProperty ;
143
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R8IMOtcLwcjyqoPFH8fqF2P> ;
144
+ rdfs:domain <http://webprotege.stanford.edu/Re2wKa5UQ9OcyzVPnqXZDn> ;
145
+ rdfs:range xsd:string ;
146
+ rdfs:label "hasCountry"@en .
147
+
148
+
149
+ ### http://webprotege.stanford.edu/R7mBDzzYd1UgyfZel4tTc2B
150
+ <http://webprotege.stanford.edu/R7mBDzzYd1UgyfZel4tTc2B> rdf:type owl:DatatypeProperty ;
151
+ rdfs:subPropertyOf owl:topDataProperty ;
152
+ rdfs:label "hasAudioProperty"@en .
153
+
154
+
155
+ ### http://webprotege.stanford.edu/R7rY0VViz9Au5Xi1WdLkiB9
156
+ <http://webprotege.stanford.edu/R7rY0VViz9Au5Xi1WdLkiB9> rdf:type owl:DatatypeProperty ;
157
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/Rm9GuQGpVGn4B3CmHmoaxl> ;
158
+ rdfs:domain <http://webprotege.stanford.edu/REFofozMBUvB1ZSMYI7UP2> ;
159
+ rdfs:range xsd:integer ;
160
+ rdfs:label "hasAge"@en .
161
+
162
+
163
+ ### http://webprotege.stanford.edu/R81WQN2oFCHcsucWi2Z8RRQ
164
+ <http://webprotege.stanford.edu/R81WQN2oFCHcsucWi2Z8RRQ> rdf:type owl:DatatypeProperty ;
165
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/RhHHShIuzreKWm4XWgYg55> ;
166
+ rdfs:domain <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
167
+ rdfs:range xsd:dateTime ;
168
+ rdfs:label "hasEndTime"@en .
169
+
170
+
171
+ ### http://webprotege.stanford.edu/R8IMOtcLwcjyqoPFH8fqF2P
172
+ <http://webprotege.stanford.edu/R8IMOtcLwcjyqoPFH8fqF2P> rdf:type owl:DatatypeProperty ;
173
+ rdfs:subPropertyOf owl:topDataProperty ;
174
+ rdfs:label "hasLocationAttribute"@en .
175
+
176
+
177
+ ### http://webprotege.stanford.edu/R8Slp7kSENUvWKqifA4p0Nc
178
+ <http://webprotege.stanford.edu/R8Slp7kSENUvWKqifA4p0Nc> rdf:type owl:DatatypeProperty ;
179
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/Rm9GuQGpVGn4B3CmHmoaxl> ;
180
+ rdfs:domain <http://webprotege.stanford.edu/REFofozMBUvB1ZSMYI7UP2> ;
181
+ rdfs:range xsd:decimal ;
182
+ rdfs:label "hasHeight"@en .
183
+
184
+
185
+ ### http://webprotege.stanford.edu/R8j7thJCl1ipPIJLiF0u32C
186
+ <http://webprotege.stanford.edu/R8j7thJCl1ipPIJLiF0u32C> rdf:type owl:DatatypeProperty ;
187
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/RhHHShIuzreKWm4XWgYg55> ;
188
+ rdfs:domain <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ,
189
+ <http://webprotege.stanford.edu/R95tXEkA9BljL3wPFQDQhNS> ;
190
+ rdfs:label "hasTimeCode"@en .
191
+
192
+
193
+ ### http://webprotege.stanford.edu/R8s11QVlQglkxdqnn1r9aQg
194
+ <http://webprotege.stanford.edu/R8s11QVlQglkxdqnn1r9aQg> rdf:type owl:DatatypeProperty ;
195
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R8IMOtcLwcjyqoPFH8fqF2P> ;
196
+ rdfs:domain <http://webprotege.stanford.edu/Re2wKa5UQ9OcyzVPnqXZDn> ;
197
+ rdfs:range xsd:string ;
198
+ rdfs:label "hasPostalCode"@en .
199
+
200
+
201
+ ### http://webprotege.stanford.edu/R9O4UCsWNtvfQLjdboFA30K
202
+ <http://webprotege.stanford.edu/R9O4UCsWNtvfQLjdboFA30K> rdf:type owl:DatatypeProperty ;
203
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/RhHHShIuzreKWm4XWgYg55> ;
204
+ rdfs:domain <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
205
+ rdfs:range xsd:dateTime ;
206
+ rdfs:label "hasStartTime"@en .
207
+
208
+
209
+ ### http://webprotege.stanford.edu/RBKux96XgsH8q69DHEcLRZs
210
+ <http://webprotege.stanford.edu/RBKux96XgsH8q69DHEcLRZs> rdf:type owl:DatatypeProperty ;
211
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/RCUwYNjao0PyVAcUenw7adO> ;
212
+ rdfs:domain <http://webprotege.stanford.edu/R29Nj9RpZQbHCZozi57WHL> ;
213
+ rdfs:range xsd:string ;
214
+ rdfs:label "hasID"@en .
215
+
216
+
217
+ ### http://webprotege.stanford.edu/RBe4GYaMNIh50M78RdHHKDf
218
+ <http://webprotege.stanford.edu/RBe4GYaMNIh50M78RdHHKDf> rdf:type owl:DatatypeProperty ;
219
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/RhHHShIuzreKWm4XWgYg55> ;
220
+ rdfs:domain <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
221
+ rdfs:range xsd:dateTime ;
222
+ rdfs:label "hasDuration"@en .
223
+
224
+
225
+ ### http://webprotege.stanford.edu/RBjjd5AolCisVyJP61JNmRv
226
+ <http://webprotege.stanford.edu/RBjjd5AolCisVyJP61JNmRv> rdf:type owl:DatatypeProperty ;
227
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R8IMOtcLwcjyqoPFH8fqF2P> ;
228
+ rdfs:domain <http://webprotege.stanford.edu/Re2wKa5UQ9OcyzVPnqXZDn> ;
229
+ rdfs:range xsd:string ;
230
+ rdfs:label "hasStreetName"@en .
231
+
232
+
233
+ ### http://webprotege.stanford.edu/RCUwYNjao0PyVAcUenw7adO
234
+ <http://webprotege.stanford.edu/RCUwYNjao0PyVAcUenw7adO> rdf:type owl:DatatypeProperty ;
235
+ rdfs:subPropertyOf owl:topDataProperty ;
236
+ rdfs:label "hasIdentifierMeasure"@en .
237
+
238
+
239
+ ### http://webprotege.stanford.edu/RD0nHzyUWAijmSRKosGLQHL
240
+ <http://webprotege.stanford.edu/RD0nHzyUWAijmSRKosGLQHL> rdf:type owl:DatatypeProperty ;
241
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/Rm9GuQGpVGn4B3CmHmoaxl> ;
242
+ rdfs:domain <http://webprotege.stanford.edu/REFofozMBUvB1ZSMYI7UP2> ;
243
+ rdfs:range xsd:integer ;
244
+ rdfs:label "hasExperienceYears"@en .
245
+
246
+
247
+ ### http://webprotege.stanford.edu/RDvUy3s7NYo86ggZDapbgGI
248
+ <http://webprotege.stanford.edu/RDvUy3s7NYo86ggZDapbgGI> rdf:type owl:DatatypeProperty ;
249
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/RshgijdwTYkRNRSTnBN1im> ;
250
+ rdfs:domain <http://webprotege.stanford.edu/RLFwu7zVX2LXbEjquykigV> ;
251
+ rdfs:range xsd:decimal ;
252
+ rdfs:label "hasLuminosity"@en .
253
+
254
+
255
+ ### http://webprotege.stanford.edu/RIjYbkyKLWUlwGKBY7sIip
256
+ <http://webprotege.stanford.edu/RIjYbkyKLWUlwGKBY7sIip> rdf:type owl:DatatypeProperty ;
257
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R7mBDzzYd1UgyfZel4tTc2B> ;
258
+ rdfs:domain <http://webprotege.stanford.edu/R95tXEkA9BljL3wPFQDQhNS> ;
259
+ rdfs:range xsd:boolean ;
260
+ rdfs:label "hasStereo"@en .
261
+
262
+
263
+ ### http://webprotege.stanford.edu/RQ9skuvGj97NN4ARJ56jX7
264
+ <http://webprotege.stanford.edu/RQ9skuvGj97NN4ARJ56jX7> rdf:type owl:DatatypeProperty ;
265
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R7mBDzzYd1UgyfZel4tTc2B> ;
266
+ rdfs:domain <http://webprotege.stanford.edu/R95tXEkA9BljL3wPFQDQhNS> ;
267
+ rdfs:range xsd:string ;
268
+ rdfs:label "hasBrand"@en .
269
+
270
+
271
+ ### http://webprotege.stanford.edu/RSepJ8R1LmVVamoVymymL7
272
+ <http://webprotege.stanford.edu/RSepJ8R1LmVVamoVymymL7> rdf:type owl:DatatypeProperty ;
273
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/RCUwYNjao0PyVAcUenw7adO> ;
274
+ rdfs:domain <http://webprotege.stanford.edu/RaLh8EKtpKbIa8K1Yycr6g> ;
275
+ rdfs:range xsd:string ;
276
+ rdfs:label "hasProjectName"@en .
277
+
278
+
279
+ ### http://webprotege.stanford.edu/RV8bcnl6pG1rjx2BETeHuh
280
+ <http://webprotege.stanford.edu/RV8bcnl6pG1rjx2BETeHuh> rdf:type owl:DatatypeProperty ;
281
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R7mBDzzYd1UgyfZel4tTc2B> ;
282
+ rdfs:domain <http://webprotege.stanford.edu/R95tXEkA9BljL3wPFQDQhNS> ;
283
+ rdfs:range xsd:decimal ;
284
+ rdfs:label "haSamplingFrequency"@en .
285
+
286
+
287
+ ### http://webprotege.stanford.edu/RYbs1PntzYIdvypPTNBzPu
288
+ <http://webprotege.stanford.edu/RYbs1PntzYIdvypPTNBzPu> rdf:type owl:DatatypeProperty ;
289
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/RshgijdwTYkRNRSTnBN1im> ;
290
+ rdfs:domain <http://webprotege.stanford.edu/RLFwu7zVX2LXbEjquykigV> ;
291
+ rdfs:range xsd:decimal ;
292
+ rdfs:label "hasHumidity"@en .
293
+
294
+
295
+ ### http://webprotege.stanford.edu/RdkZ3V1e5oCw3UbK76grQd
296
+ <http://webprotege.stanford.edu/RdkZ3V1e5oCw3UbK76grQd> rdf:type owl:DatatypeProperty ;
297
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/RCUwYNjao0PyVAcUenw7adO> ;
298
+ rdfs:domain <http://webprotege.stanford.edu/R29Nj9RpZQbHCZozi57WHL> ;
299
+ rdfs:range xsd:string ;
300
+ rdfs:label "hasSerialNumber"@en .
301
+
302
+
303
+ ### http://webprotege.stanford.edu/RhHHShIuzreKWm4XWgYg55
304
+ <http://webprotege.stanford.edu/RhHHShIuzreKWm4XWgYg55> rdf:type owl:DatatypeProperty ;
305
+ rdfs:subPropertyOf owl:topDataProperty ;
306
+ rdfs:label "hasTemporalMeasure"@en .
307
+
308
+
309
+ ### http://webprotege.stanford.edu/RhqGp8Bs54YJWpTgkCRMoe
310
+ <http://webprotege.stanford.edu/RhqGp8Bs54YJWpTgkCRMoe> rdf:type owl:DatatypeProperty ;
311
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/RshgijdwTYkRNRSTnBN1im> ;
312
+ rdfs:domain <http://webprotege.stanford.edu/RLFwu7zVX2LXbEjquykigV> ,
313
+ <http://webprotege.stanford.edu/Rr7Uv68Nflc6ZqdLrgzFEt> ;
314
+ rdfs:range xsd:decimal ;
315
+ rdfs:label "hasTemperature"@en .
316
+
317
+
318
+ ### http://webprotege.stanford.edu/Rm9GuQGpVGn4B3CmHmoaxl
319
+ <http://webprotege.stanford.edu/Rm9GuQGpVGn4B3CmHmoaxl> rdf:type owl:DatatypeProperty ;
320
+ rdfs:subPropertyOf owl:topDataProperty ;
321
+ rdfs:label "hasPersonalAttribute"@en .
322
+
323
+
324
+ ### http://webprotege.stanford.edu/RshgijdwTYkRNRSTnBN1im
325
+ <http://webprotege.stanford.edu/RshgijdwTYkRNRSTnBN1im> rdf:type owl:DatatypeProperty ;
326
+ rdfs:subPropertyOf owl:topDataProperty ;
327
+ rdfs:label "hasEnvironmentalMeasure"@en .
328
+
329
+
330
+ ### http://webprotege.stanford.edu/Rx7d44GStIG5ECXyKIevBj
331
+ <http://webprotege.stanford.edu/Rx7d44GStIG5ECXyKIevBj> rdf:type owl:DatatypeProperty ;
332
+ rdfs:subPropertyOf <http://webprotege.stanford.edu/R7mBDzzYd1UgyfZel4tTc2B> ;
333
+ rdfs:domain <http://webprotege.stanford.edu/R95tXEkA9BljL3wPFQDQhNS> ;
334
+ rdfs:range xsd:string ;
335
+ rdfs:label "hasBitDepth"@en .
336
+
337
+
338
+ #################################################################
339
+ # Classes
340
+ #################################################################
341
+
342
+ ### http://webprotege.stanford.edu/R29Nj9RpZQbHCZozi57WHL
343
+ <http://webprotege.stanford.edu/R29Nj9RpZQbHCZozi57WHL> rdf:type owl:Class ;
344
+ rdfs:subClassOf owl:Thing ;
345
+ rdfs:label "WorkEquipment"@en .
346
+
347
+
348
+ ### http://webprotege.stanford.edu/R2jeyRvPp5xgOybbNxJ5GR
349
+ <http://webprotege.stanford.edu/R2jeyRvPp5xgOybbNxJ5GR> rdf:type owl:Class ;
350
+ rdfs:subClassOf <http://webprotege.stanford.edu/RDJeOPBCNiUd4qtyqCxvEHG> ;
351
+ rdfs:label "PCB"@en .
352
+
353
+
354
+ ### http://webprotege.stanford.edu/R79iDSpSFsdmxY0QKtFWvnI
355
+ <http://webprotege.stanford.edu/R79iDSpSFsdmxY0QKtFWvnI> rdf:type owl:Class ;
356
+ rdfs:subClassOf <http://webprotege.stanford.edu/REFofozMBUvB1ZSMYI7UP2> ;
357
+ rdfs:label "Supervisor"@en .
358
+
359
+
360
+ ### http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb
361
+ <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> rdf:type owl:Class ;
362
+ rdfs:label "Motion"@en .
363
+
364
+
365
+ ### http://webprotege.stanford.edu/R7XIzcGnOLzgR9oEuRW9SCF
366
+ <http://webprotege.stanford.edu/R7XIzcGnOLzgR9oEuRW9SCF> rdf:type owl:Class ;
367
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8BZScG7wdTIQpssYX9ZDTP> ;
368
+ rdfs:label "Hammer"@en .
369
+
370
+
371
+ ### http://webprotege.stanford.edu/R7a9qBHcfkQU5JnmS1cycLd
372
+ <http://webprotege.stanford.edu/R7a9qBHcfkQU5JnmS1cycLd> rdf:type owl:Class ;
373
+ rdfs:subClassOf <http://webprotege.stanford.edu/R29Nj9RpZQbHCZozi57WHL> ;
374
+ rdfs:label "Machinery"@en .
375
+
376
+
377
+ ### http://webprotege.stanford.edu/R7cnU8enzj6g853X3isXqrB
378
+ <http://webprotege.stanford.edu/R7cnU8enzj6g853X3isXqrB> rdf:type owl:Class ;
379
+ rdfs:subClassOf <http://webprotege.stanford.edu/RfraaLiY680VndQTbnJuxA> ;
380
+ rdfs:label "TorsoSafety"@en .
381
+
382
+
383
+ ### http://webprotege.stanford.edu/R7ibPHzb0n0KVP9nbQpU5ee
384
+ <http://webprotege.stanford.edu/R7ibPHzb0n0KVP9nbQpU5ee> rdf:type owl:Class ;
385
+ rdfs:label "DataAcquisitionEquipment"@en .
386
+
387
+
388
+ ### http://webprotege.stanford.edu/R7mn1u3qc7RwUV4colDYI7n
389
+ <http://webprotege.stanford.edu/R7mn1u3qc7RwUV4colDYI7n> rdf:type owl:Class ;
390
+ rdfs:subClassOf <http://webprotege.stanford.edu/REFofozMBUvB1ZSMYI7UP2> ;
391
+ rdfs:label "Trainee"@en .
392
+
393
+
394
+ ### http://webprotege.stanford.edu/R7s2keme2UKZQY0kfkbR0oT
395
+ <http://webprotege.stanford.edu/R7s2keme2UKZQY0kfkbR0oT> rdf:type owl:Class ;
396
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8c4dwfcf0khAIX9pI8PexJ> ;
397
+ rdfs:label "MasticCultivation"@en .
398
+
399
+
400
+ ### http://webprotege.stanford.edu/R7ycKhW9Tq5LKjHZ13pJsrU
401
+ <http://webprotege.stanford.edu/R7ycKhW9Tq5LKjHZ13pJsrU> rdf:type owl:Class ;
402
+ rdfs:subClassOf <http://webprotege.stanford.edu/RaLh8EKtpKbIa8K1Yycr6g> ;
403
+ rdfs:label "Industrial"@en .
404
+
405
+
406
+ ### http://webprotege.stanford.edu/R80A6RRgkhASfHjb4wh0zhx
407
+ <http://webprotege.stanford.edu/R80A6RRgkhASfHjb4wh0zhx> rdf:type owl:Class ;
408
+ rdfs:subClassOf <http://webprotege.stanford.edu/RcaUGQKzgfwOrwXZCmelAP> ;
409
+ rdfs:label "EgoCentricCamera"@en .
410
+
411
+
412
+ ### http://webprotege.stanford.edu/R81iHZBvR9VBh1qEmLbD2R8
413
+ <http://webprotege.stanford.edu/R81iHZBvR9VBh1qEmLbD2R8> rdf:type owl:Class ;
414
+ rdfs:subClassOf <http://webprotege.stanford.edu/R9skEAPq5XDWnwOptgdeYxF> ;
415
+ rdfs:comment "TBD where to put it"^^xsd:string ;
416
+ rdfs:label "Pipe"@en .
417
+
418
+
419
+ ### http://webprotege.stanford.edu/R87GvHRh7hGEkV26ihOTRXM
420
+ <http://webprotege.stanford.edu/R87GvHRh7hGEkV26ihOTRXM> rdf:type owl:Class ;
421
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8c4dwfcf0khAIX9pI8PexJ> ;
422
+ rdfs:label "Tapestry"@en .
423
+
424
+
425
+ ### http://webprotege.stanford.edu/R8BZScG7wdTIQpssYX9ZDTP
426
+ <http://webprotege.stanford.edu/R8BZScG7wdTIQpssYX9ZDTP> rdf:type owl:Class ;
427
+ rdfs:subClassOf <http://webprotege.stanford.edu/R9dZolU4P4z1LZTQsA6tOJM> ;
428
+ rdfs:label "OneHandedTool"@en .
429
+
430
+
431
+ ### http://webprotege.stanford.edu/R8PR5sR8TlbTGqYl6U6rcOS
432
+ <http://webprotege.stanford.edu/R8PR5sR8TlbTGqYl6U6rcOS> rdf:type owl:Class ;
433
+ rdfs:subClassOf <http://webprotege.stanford.edu/RBsQGppxY1l6oP69L8GGAzl> ;
434
+ rdfs:label "ContactMicrophone"@en .
435
+
436
+
437
+ ### http://webprotege.stanford.edu/R8TCukJmpPpBOmfQyd6QyVI
438
+ <http://webprotege.stanford.edu/R8TCukJmpPpBOmfQyd6QyVI> rdf:type owl:Class ;
439
+ rdfs:subClassOf <http://webprotege.stanford.edu/R7a9qBHcfkQU5JnmS1cycLd> ;
440
+ rdfs:label "ElectricMachinery"@en .
441
+
442
+
443
+ ### http://webprotege.stanford.edu/R8c4dwfcf0khAIX9pI8PexJ
444
+ <http://webprotege.stanford.edu/R8c4dwfcf0khAIX9pI8PexJ> rdf:type owl:Class ;
445
+ rdfs:subClassOf <http://webprotege.stanford.edu/RaLh8EKtpKbIa8K1Yycr6g> ;
446
+ rdfs:label "Craft"@en .
447
+
448
+
449
+ ### http://webprotege.stanford.edu/R8rHmvwvlLNFGdsarvk6x2e
450
+ <http://webprotege.stanford.edu/R8rHmvwvlLNFGdsarvk6x2e> rdf:type owl:Class ;
451
+ rdfs:subClassOf <http://webprotege.stanford.edu/RePLQM6TSU1ZDpq9RXLukQ> ;
452
+ rdfs:label "CalibrationTool"@en .
453
+
454
+
455
+ ### http://webprotege.stanford.edu/R8z7tFuRcmKmbPa4xxvZKSD
456
+ <http://webprotege.stanford.edu/R8z7tFuRcmKmbPa4xxvZKSD> rdf:type owl:Class ;
457
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8BZScG7wdTIQpssYX9ZDTP> ;
458
+ rdfs:label "Pliers"@en .
459
+
460
+
461
+ ### http://webprotege.stanford.edu/R93AGKkZKZnmzlenXes9TZK
462
+ <http://webprotege.stanford.edu/R93AGKkZKZnmzlenXes9TZK> rdf:type owl:Class ;
463
+ rdfs:subClassOf <http://webprotege.stanford.edu/R81iHZBvR9VBh1qEmLbD2R8> ;
464
+ rdfs:label "HelpingPipe"@en .
465
+
466
+
467
+ ### http://webprotege.stanford.edu/R95tXEkA9BljL3wPFQDQhNS
468
+ <http://webprotege.stanford.edu/R95tXEkA9BljL3wPFQDQhNS> rdf:type owl:Class ;
469
+ rdfs:subClassOf <http://webprotege.stanford.edu/R7ibPHzb0n0KVP9nbQpU5ee> ;
470
+ rdfs:label "Audio"@en .
471
+
472
+
473
+ ### http://webprotege.stanford.edu/R9CGRdWkBqwt4A4OQZq5vS
474
+ <http://webprotege.stanford.edu/R9CGRdWkBqwt4A4OQZq5vS> rdf:type owl:Class ;
475
+ rdfs:subClassOf <http://webprotege.stanford.edu/RfraaLiY680VndQTbnJuxA> ;
476
+ rdfs:label "HandSafety"@en .
477
+
478
+
479
+ ### http://webprotege.stanford.edu/R9GsQF8mNa3QshO7ytu25l0
480
+ <http://webprotege.stanford.edu/R9GsQF8mNa3QshO7ytu25l0> rdf:type owl:Class ;
481
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8BZScG7wdTIQpssYX9ZDTP> ;
482
+ rdfs:label "Mold"@en .
483
+
484
+
485
+ ### http://webprotege.stanford.edu/R9HehWtxN0tMR2QYOeuolc4
486
+ <http://webprotege.stanford.edu/R9HehWtxN0tMR2QYOeuolc4> rdf:type owl:Class ;
487
+ rdfs:subClassOf <http://webprotege.stanford.edu/R7UN9jauVxOnV6Y052I3fEb> ;
488
+ rdfs:label "AssemblyMotion"@en .
489
+
490
+
491
+ ### http://webprotege.stanford.edu/R9dZolU4P4z1LZTQsA6tOJM
492
+ <http://webprotege.stanford.edu/R9dZolU4P4z1LZTQsA6tOJM> rdf:type owl:Class ;
493
+ rdfs:subClassOf <http://webprotege.stanford.edu/R29Nj9RpZQbHCZozi57WHL> ;
494
+ rdfs:label "HandTool"@en .
495
+
496
+
497
+ ### http://webprotege.stanford.edu/R9nJbjGucfZBfnDShMDMnIC
498
+ <http://webprotege.stanford.edu/R9nJbjGucfZBfnDShMDMnIC> rdf:type owl:Class ;
499
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8c4dwfcf0khAIX9pI8PexJ> ;
500
+ rdfs:label "SilverSmithing"@en .
501
+
502
+
503
+ ### http://webprotege.stanford.edu/R9qKElVxgCua1kpFY9ofQjO
504
+ <http://webprotege.stanford.edu/R9qKElVxgCua1kpFY9ofQjO> rdf:type owl:Class ;
505
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8c4dwfcf0khAIX9pI8PexJ> ;
506
+ rdfs:label "PorcelaineMaking"@en .
507
+
508
+
509
+ ### http://webprotege.stanford.edu/R9skEAPq5XDWnwOptgdeYxF
510
+ <http://webprotege.stanford.edu/R9skEAPq5XDWnwOptgdeYxF> rdf:type owl:Class ;
511
+ rdfs:subClassOf <http://webprotege.stanford.edu/R9dZolU4P4z1LZTQsA6tOJM> ;
512
+ rdfs:label "TwoHandedTool"@en .
513
+
514
+
515
+ ### http://webprotege.stanford.edu/RBJ7FH4VFBVRfeEPS7G0LGL
516
+ <http://webprotege.stanford.edu/RBJ7FH4VFBVRfeEPS7G0LGL> rdf:type owl:Class ;
517
+ rdfs:subClassOf <http://webprotege.stanford.edu/R7a9qBHcfkQU5JnmS1cycLd> ;
518
+ rdfs:label "NonElectricMachinery"@en .
519
+
520
+
521
+ ### http://webprotege.stanford.edu/RBViq4XL1ghfah2SJRz6xuI
522
+ <http://webprotege.stanford.edu/RBViq4XL1ghfah2SJRz6xuI> rdf:type owl:Class ;
523
+ rdfs:subClassOf <http://webprotege.stanford.edu/R9dZolU4P4z1LZTQsA6tOJM> ;
524
+ rdfs:label "GrindingTool"@en .
525
+
526
+
527
+ ### http://webprotege.stanford.edu/RBedcVJEkGfWsdwm2igA0Pg
528
+ <http://webprotege.stanford.edu/RBedcVJEkGfWsdwm2igA0Pg> rdf:type owl:Class ;
529
+ rdfs:subClassOf <http://webprotege.stanford.edu/R9dZolU4P4z1LZTQsA6tOJM> ;
530
+ rdfs:label "AirTool"@en .
531
+
532
+
533
+ ### http://webprotege.stanford.edu/RBmqVfvNYiywdzzgwF6AZ3o
534
+ <http://webprotege.stanford.edu/RBmqVfvNYiywdzzgwF6AZ3o> rdf:type owl:Class ;
535
+ rdfs:subClassOf <http://webprotege.stanford.edu/RBJ7FH4VFBVRfeEPS7G0LGL> ;
536
+ rdfs:label "Final oven"@en .
537
+
538
+
539
+ ### http://webprotege.stanford.edu/RBmxtAcd4SVZCdsX42J5iFW
540
+ <http://webprotege.stanford.edu/RBmxtAcd4SVZCdsX42J5iFW> rdf:type owl:Class ;
541
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8c4dwfcf0khAIX9pI8PexJ> ;
542
+ rdfs:label "GoldSmithing"@en .
543
+
544
+
545
+ ### http://webprotege.stanford.edu/RBsQGppxY1l6oP69L8GGAzl
546
+ <http://webprotege.stanford.edu/RBsQGppxY1l6oP69L8GGAzl> rdf:type owl:Class ;
547
+ rdfs:subClassOf <http://webprotege.stanford.edu/R95tXEkA9BljL3wPFQDQhNS> ;
548
+ rdfs:label "Microphone"@en .
549
+
550
+
551
+ ### http://webprotege.stanford.edu/RBwkPw4dKZRuxOlGCz2r83h
552
+ <http://webprotege.stanford.edu/RBwkPw4dKZRuxOlGCz2r83h> rdf:type owl:Class ;
553
+ rdfs:subClassOf <http://webprotege.stanford.edu/RLFwu7zVX2LXbEjquykigV> ;
554
+ rdfs:label "Warehouse"@en .
555
+
556
+
557
+ ### http://webprotege.stanford.edu/RC10o2v3G4ZS4kZioODlR8h
558
+ <http://webprotege.stanford.edu/RC10o2v3G4ZS4kZioODlR8h> rdf:type owl:Class ;
559
+ rdfs:subClassOf <http://webprotege.stanford.edu/R9HehWtxN0tMR2QYOeuolc4> ;
560
+ rdfs:label "PCBConnection"@en .
561
+
562
 
563
+ ### http://webprotege.stanford.edu/RC9osaNU4wwUW7mtS0UrvCC
564
+ <http://webprotege.stanford.edu/RC9osaNU4wwUW7mtS0UrvCC> rdf:type owl:Class ;
565
+ rdfs:subClassOf <http://webprotege.stanford.edu/RLFwu7zVX2LXbEjquykigV> ;
566
+ rdfs:label "Factory"@en .
 
 
 
567
 
568
+
569
+ ### http://webprotege.stanford.edu/RCH90qtns97vqh7Zx5JGmff
570
+ <http://webprotege.stanford.edu/RCH90qtns97vqh7Zx5JGmff> rdf:type owl:Class ;
571
+ rdfs:subClassOf <http://webprotege.stanford.edu/R7ycKhW9Tq5LKjHZ13pJsrU> ;
572
+ rdfs:label "Riveting"@en .
573
+
574
+
575
+ ### http://webprotege.stanford.edu/RCIaSVXNWFBwIIdB0vxIvBy
576
+ <http://webprotege.stanford.edu/RCIaSVXNWFBwIIdB0vxIvBy> rdf:type owl:Class ;
577
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8c4dwfcf0khAIX9pI8PexJ> ;
578
+ rdfs:label "GloveMaking"@en .
579
+
580
+
581
+ ### http://webprotege.stanford.edu/RCLgAAbQNJe2kLWPwuGK8G
582
+ <http://webprotege.stanford.edu/RCLgAAbQNJe2kLWPwuGK8G> rdf:type owl:Class ;
583
+ rdfs:subClassOf <http://webprotege.stanford.edu/R9HehWtxN0tMR2QYOeuolc4> ;
584
+ rdfs:label "BoardPositioning"@en .
585
+
586
+
587
+ ### http://webprotege.stanford.edu/RCjM4IY6wfoPBj1GNh5JetA
588
+ <http://webprotege.stanford.edu/RCjM4IY6wfoPBj1GNh5JetA> rdf:type owl:Class ;
589
+ rdfs:subClassOf <http://webprotege.stanford.edu/R7ycKhW9Tq5LKjHZ13pJsrU> ;
590
+ rdfs:label "TelevisionAssembly"@en .
591
+
592
+
593
+ ### http://webprotege.stanford.edu/RCox7IXnNIGcSQrVNOMBDKR
594
+ <http://webprotege.stanford.edu/RCox7IXnNIGcSQrVNOMBDKR> rdf:type owl:Class ;
595
+ rdfs:subClassOf <http://webprotege.stanford.edu/RcaUGQKzgfwOrwXZCmelAP> ;
596
+ rdfs:label "ExoCentricCamera"@en .
597
+
598
+
599
+ ### http://webprotege.stanford.edu/RDF98OAM6l3C7XYALGYg8UU
600
+ <http://webprotege.stanford.edu/RDF98OAM6l3C7XYALGYg8UU> rdf:type owl:Class ;
601
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8BZScG7wdTIQpssYX9ZDTP> ;
602
+ rdfs:label "File"@en .
603
+
604
+
605
+ ### http://webprotege.stanford.edu/RDJeOPBCNiUd4qtyqCxvEHG
606
+ <http://webprotege.stanford.edu/RDJeOPBCNiUd4qtyqCxvEHG> rdf:type owl:Class ;
607
+ rdfs:subClassOf owl:Thing ;
608
+ rdfs:label "Component"@en .
609
+
610
+
611
+ ### http://webprotege.stanford.edu/RDLETfTKIi5Id4u9ksXbAP7
612
+ <http://webprotege.stanford.edu/RDLETfTKIi5Id4u9ksXbAP7> rdf:type owl:Class ;
613
+ rdfs:subClassOf <http://webprotege.stanford.edu/R7ycKhW9Tq5LKjHZ13pJsrU> ;
614
+ rdfs:label "Packaging"@en .
615
+
616
+
617
+ ### http://webprotege.stanford.edu/RDLXQJoGXPBLHToFiH06vyq
618
+ <http://webprotege.stanford.edu/RDLXQJoGXPBLHToFiH06vyq> rdf:type owl:Class ;
619
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8BZScG7wdTIQpssYX9ZDTP> ;
620
+ rdfs:label "Ruler"@en .
621
+
622
+
623
+ ### http://webprotege.stanford.edu/RDPX24XKwZBjH25u2982tNZ
624
+ <http://webprotege.stanford.edu/RDPX24XKwZBjH25u2982tNZ> rdf:type owl:Class ;
625
+ rdfs:subClassOf <http://webprotege.stanford.edu/RLFwu7zVX2LXbEjquykigV> ;
626
+ rdfs:label "MasticField"@en .
627
+
628
+
629
+ ### http://webprotege.stanford.edu/RDQt1nB0j1KjA2AUWdGRG5b
630
+ <http://webprotege.stanford.edu/RDQt1nB0j1KjA2AUWdGRG5b> rdf:type owl:Class ;
631
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8c4dwfcf0khAIX9pI8PexJ> ;
632
+ rdfs:label "NauticalSealing"@en .
633
+
634
+
635
+ ### http://webprotege.stanford.edu/RDYXIMKCHJclczC057WPChf
636
+ <http://webprotege.stanford.edu/RDYXIMKCHJclczC057WPChf> rdf:type owl:Class ;
637
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8BZScG7wdTIQpssYX9ZDTP> ;
638
+ rdfs:label "Cutter"@en .
639
+
640
+
641
+ ### http://webprotege.stanford.edu/RDopuJ5SRzkMSPsJiZ5hX7e
642
+ <http://webprotege.stanford.edu/RDopuJ5SRzkMSPsJiZ5hX7e> rdf:type owl:Class ;
643
+ rdfs:subClassOf <http://webprotege.stanford.edu/R81iHZBvR9VBh1qEmLbD2R8> ;
644
+ rdfs:label "BlowPipe"@en .
645
+
646
+
647
+ ### http://webprotege.stanford.edu/RDsMUBZAo7P7Zt49Lj4h9Cx
648
+ <http://webprotege.stanford.edu/RDsMUBZAo7P7Zt49Lj4h9Cx> rdf:type owl:Class ;
649
+ rdfs:subClassOf <http://webprotege.stanford.edu/RfraaLiY680VndQTbnJuxA> ;
650
+ rdfs:label "LegLowerBodySafety"@en .
651
+
652
+
653
+ ### http://webprotege.stanford.edu/RDsqfEXKbE8kmtEZbsRfvmm
654
+ <http://webprotege.stanford.edu/RDsqfEXKbE8kmtEZbsRfvmm> rdf:type owl:Class ;
655
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8BZScG7wdTIQpssYX9ZDTP> ;
656
+ rdfs:label "Scissors"@en .
657
+
658
+
659
+ ### http://webprotege.stanford.edu/RDuFcH4MCIhfLaFDpE2t9rn
660
+ <http://webprotege.stanford.edu/RDuFcH4MCIhfLaFDpE2t9rn> rdf:type owl:Class ;
661
+ rdfs:subClassOf <http://webprotege.stanford.edu/RBsQGppxY1l6oP69L8GGAzl> ;
662
+ rdfs:label "DetachedMicrophone"@en .
663
+
664
+
665
+ ### http://webprotege.stanford.edu/RDyyCuniBcb9EwFGg44ehAG
666
+ <http://webprotege.stanford.edu/RDyyCuniBcb9EwFGg44ehAG> rdf:type owl:Class ;
667
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8c4dwfcf0khAIX9pI8PexJ> ;
668
+ rdfs:label "SilkWeaving"@en .
669
+
670
+
671
+ ### http://webprotege.stanford.edu/REFofozMBUvB1ZSMYI7UP2
672
+ <http://webprotege.stanford.edu/REFofozMBUvB1ZSMYI7UP2> rdf:type owl:Class ;
673
+ rdfs:subClassOf owl:Thing ;
674
+ rdfs:label "Person"@en .
675
+
676
+
677
+ ### http://webprotege.stanford.edu/RLFwu7zVX2LXbEjquykigV
678
+ <http://webprotege.stanford.edu/RLFwu7zVX2LXbEjquykigV> rdf:type owl:Class ;
679
+ rdfs:label "Environment"@en .
680
+
681
+
682
+ ### http://webprotege.stanford.edu/RQtQ5I8T6kQxisYX54Dyl
683
+ <http://webprotege.stanford.edu/RQtQ5I8T6kQxisYX54Dyl> rdf:type owl:Class ;
684
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8c4dwfcf0khAIX9pI8PexJ> ;
685
+ rdfs:label "WoodManufacturing"@en .
686
+
687
+
688
+ ### http://webprotege.stanford.edu/RSwq5x4HzKZD60jFN7ewtD
689
+ <http://webprotege.stanford.edu/RSwq5x4HzKZD60jFN7ewtD> rdf:type owl:Class ;
690
+ rdfs:subClassOf <http://webprotege.stanford.edu/R9HehWtxN0tMR2QYOeuolc4> ;
691
+ rdfs:label "ScrewingMotion"@en .
692
+
693
+
694
+ ### http://webprotege.stanford.edu/RY9inqCLNvf3EYBFeg1tME
695
+ <http://webprotege.stanford.edu/RY9inqCLNvf3EYBFeg1tME> rdf:type owl:Class ;
696
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8TCukJmpPpBOmfQyd6QyVI> ;
697
+ rdfs:label "Grinder"@en .
698
+
699
+
700
+ ### http://webprotege.stanford.edu/RYeCID4hHDHUEBGtUfjJod
701
+ <http://webprotege.stanford.edu/RYeCID4hHDHUEBGtUfjJod> rdf:type owl:Class ;
702
+ rdfs:subClassOf <http://webprotege.stanford.edu/RDJeOPBCNiUd4qtyqCxvEHG> ;
703
+ rdfs:label "Chassis"@en .
704
+
705
+
706
+ ### http://webprotege.stanford.edu/RaLh8EKtpKbIa8K1Yycr6g
707
+ <http://webprotege.stanford.edu/RaLh8EKtpKbIa8K1Yycr6g> rdf:type owl:Class ;
708
+ rdfs:label "JobType"@en .
709
+
710
+
711
+ ### http://webprotege.stanford.edu/RcaUGQKzgfwOrwXZCmelAP
712
+ <http://webprotege.stanford.edu/RcaUGQKzgfwOrwXZCmelAP> rdf:type owl:Class ;
713
+ rdfs:subClassOf <http://webprotege.stanford.edu/R7ibPHzb0n0KVP9nbQpU5ee> ;
714
+ rdfs:label "Video"@en .
715
+
716
+
717
+ ### http://webprotege.stanford.edu/Rcd75tjZMp0OnsYj4bk1Rh
718
+ <http://webprotege.stanford.edu/Rcd75tjZMp0OnsYj4bk1Rh> rdf:type owl:Class ;
719
+ rdfs:subClassOf <http://webprotege.stanford.edu/RfraaLiY680VndQTbnJuxA> ;
720
+ rdfs:label "HeadSafety"@en .
721
+
722
+
723
+ ### http://webprotege.stanford.edu/Re2wKa5UQ9OcyzVPnqXZDn
724
+ <http://webprotege.stanford.edu/Re2wKa5UQ9OcyzVPnqXZDn> rdf:type owl:Class ;
725
+ rdfs:subClassOf owl:Thing ;
726
+ rdfs:label "Address"@en .
727
+
728
+
729
+ ### http://webprotege.stanford.edu/RePLQM6TSU1ZDpq9RXLukQ
730
+ <http://webprotege.stanford.edu/RePLQM6TSU1ZDpq9RXLukQ> rdf:type owl:Class ;
731
+ rdfs:subClassOf <http://webprotege.stanford.edu/R7ibPHzb0n0KVP9nbQpU5ee> ;
732
+ rdfs:label "Mocap"@en .
733
+
734
+
735
+ ### http://webprotege.stanford.edu/RfraaLiY680VndQTbnJuxA
736
+ <http://webprotege.stanford.edu/RfraaLiY680VndQTbnJuxA> rdf:type owl:Class ;
737
+ rdfs:subClassOf <http://webprotege.stanford.edu/R29Nj9RpZQbHCZozi57WHL> ;
738
+ rdfs:label "SafetyEquipment"@en .
739
+
740
+
741
+ ### http://webprotege.stanford.edu/RoOWefJHo2YiYvB2B8aYug
742
+ <http://webprotege.stanford.edu/RoOWefJHo2YiYvB2B8aYug> rdf:type owl:Class ;
743
+ rdfs:subClassOf <http://webprotege.stanford.edu/R29Nj9RpZQbHCZozi57WHL> ;
744
+ rdfs:label "MeasuringTool"@en .
745
+
746
+
747
+ ### http://webprotege.stanford.edu/RpkBXFTtNSdeGd9IpTe0Y8
748
+ <http://webprotege.stanford.edu/RpkBXFTtNSdeGd9IpTe0Y8> rdf:type owl:Class ;
749
+ rdfs:subClassOf <http://webprotege.stanford.edu/REFofozMBUvB1ZSMYI7UP2> ;
750
+ rdfs:label "Expert"@en .
751
+
752
+
753
+ ### http://webprotege.stanford.edu/Rr7Uv68Nflc6ZqdLrgzFEt
754
+ <http://webprotege.stanford.edu/Rr7Uv68Nflc6ZqdLrgzFEt> rdf:type owl:Class ;
755
+ rdfs:subClassOf <http://webprotege.stanford.edu/RBJ7FH4VFBVRfeEPS7G0LGL> ;
756
+ rdfs:label "Oven"@en .
757
+
758
+
759
+ ### http://webprotege.stanford.edu/RvgYraFZGS8eYKjsoROnxF
760
+ <http://webprotege.stanford.edu/RvgYraFZGS8eYKjsoROnxF> rdf:type owl:Class ;
761
+ rdfs:subClassOf <http://webprotege.stanford.edu/R8c4dwfcf0khAIX9pI8PexJ> ;
762
+ rdfs:label "Glassblowing"@en .
763
+
764
+
765
+ ### http://webprotege.stanford.edu/RxR7zYCJonkcq0y4yBAgD5
766
+ <http://webprotege.stanford.edu/RxR7zYCJonkcq0y4yBAgD5> rdf:type owl:Class ;
767
+ rdfs:subClassOf <http://webprotege.stanford.edu/R9dZolU4P4z1LZTQsA6tOJM> ;
768
+ rdfs:comment "TBD where to put it"^^xsd:string ;
769
+ rdfs:label "Straightener"@en .
770
+
771
+
772
+ ### Generated by the OWL API (version 4.5.13) https://github.com/owlcs/owlapi
773
+ '''
774
+ DEFAULT_SYSTEM_PROMPT = "Tu réponds à la question de l'utilisateur."
775
 
776
  class HuggingFaceLogin:
777
  """Handles authentication to the Hugging Face Hub using environment variables or explicit tokens."""
778
  def __init__(self, env_token_key: str = "HF_TOKEN"):
779
+ """Initialize the login handler.
780
+
781
+ Args:
782
+ env_token_key (str): Environment variable key containing the token. Defaults to "HF_TOKEN".
783
+ """
784
  self.token = os.getenv(env_token_key)
785
 
786
  def login(self, token: str = None) -> bool:
787
+ """Authenticate with the Hugging Face Hub.
788
+
789
+ Args:
790
+ token (Optional[str]): Optional explicit token. If not provided, uses token from environment.
791
+
792
+ Returns:
793
+ bool: True if login successful, False otherwise.
794
+
795
+ Raises:
796
+ ValueError: If no token is available (neither in env nor passed explicitly).
797
+ """
798
+
799
+ if not self.token:
800
  raise ValueError("No authentication token provided. Set HF_TOKEN environment variable or pass token explicitly.")
801
  try:
802
  print("Logging in to the Hugging Face Hub...")
803
+ login(token=self.token)
804
  return True
805
  except Exception as e:
806
  print(f"Login failed: {str(e)}")
807
  return False
808
 
809
+ model_config_4bit = BitsAndBytesConfig(
810
+ load_in_4bit = True,
811
+ bnb_4bit_use_double_quant = True,
812
+ bnb_4bit_quant_type = "nf4",
813
+ bnb_4bit_compute_dtype=torch.float16
814
+ )
815
+
816
+ model_config_8bit = BitsAndBytesConfig(
817
+ load_in_8bit=True,
818
+ llm_int8_threshold=6.0,
819
+ llm_int8_has_fp16_weight=False,
820
+ bnb_8bit_compute_dtype=torch.float16
821
+ )
822
+
823
+ if torch.cuda.is_available():
824
+ model_id = "meta-llama/Llama-3.1-8B-Instruct"
825
+ model = AutoModelForCausalLM.from_pretrained(model_id,
826
+ quantization_config=model_config_8bit,
827
+ device_map="auto")
828
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
829
+
830
+ # New helper function to create a thinking message
831
+ def create_thinking_message(content: str, status: str = None) -> Dict[str, Any]:
832
+ """Creates a thinking message with metadata for display in the chatbot."""
833
+ return {
834
+ "role": "assistant",
835
+ "content": content,
836
+ "metadata": {
837
+ "title": "🧠 Réflexion",
838
+ "status": status
839
+ }
840
+ }
841
 
842
  @spaces.GPU
843
+ def generate(
844
  message: str,
845
+ chat_history: list[dict],
846
+ knowledge: str, # added knowledge parameter
847
  system_prompt: str = DEFAULT_SYSTEM_PROMPT,
848
+ max_new_tokens: int = 1024,
849
+ temperature: float = 0.2,
850
  top_p: float = 0.8,
851
  top_k: int = 50,
852
+ repetition_penalty: float = 1.0
853
+ ) -> Iterator[Dict[str, Any]]:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
854
  try:
855
+ thinking_conversation = []
 
856
  if system_prompt:
857
+ thinking_conversation.append({"role": "system",
858
+ "content": system_prompt})
 
859
  if knowledge:
860
+ thinking_conversation.append({"role": "assistant",
861
+ "content": f"Voici le texte existant que je dois comprendre: {knowledge}\n\nJe vais l'analyser étape par étape."})
862
+
863
+ thinking_conversation += chat_history
864
+ # Thinking prompt
 
 
 
 
 
 
865
  thinking_prompt = message + "\n\nRéfléchis étape par étape. Identifie d'abord les entités, puis les relations, puis organise hiérarchiquement avant de formaliser."
866
+
867
+ thinking_conversation.append({"role": "user",
868
+ "content": thinking_prompt})
869
+ thinking_message = create_thinking_message(content="Réflexion en cours...",
870
+ status="pending")
871
+ print("Yielding thinking_message\n")
872
+ yield thinking_message
873
+
874
  thinking_result = generate_llm_response(
875
+ thinking_conversation,
876
+ max_new_tokens=max_new_tokens * 2,
877
  temperature=temperature,
878
  top_p=top_p,
879
  top_k=top_k,
880
  repetition_penalty=repetition_penalty
881
  )
882
+
883
+ thinking_message = create_thinking_message(content=thinking_result,
884
+ status="done")
885
+ print("Done with thinking !\n Thinking message: ", thinking_message)
886
+ yield thinking_message
887
 
888
+ # Generate Final Answer
 
 
 
 
 
 
 
 
889
  final_conversation = []
890
+ final_conversation.append(
891
+ {"role": "system",
892
+ "content": system_prompt})
893
  if knowledge:
894
+ final_conversation.append(
895
+ {"role": "assistant",
896
+ "content": f"J'ai pris en compte le document {knowledge} et j'ai réfléchi étape par étape dessus."})
897
 
898
+ final_conversation += chat_history
899
+ final_conversation.append(
900
+ {"role": "user",
901
+ "content": message}
902
+ )
903
+ final_conversation.append(
904
+ {"role": "assistant",
905
+ "content": f"J'ai procédé à une analyse approfondie dont voici le résultat: \n{thinking_result}\n Maintenant, je vais donner une réponse finale."}
906
+ )
907
+ print("Finale conversation looks like: ", final_conversation)
 
 
908
  final_answer = generate_llm_response(
909
  final_conversation,
910
  max_new_tokens=max_new_tokens,
911
+ temperature=temperature * 0.8, # Even lower temperature for final answer
912
  top_p=top_p,
913
  top_k=top_k,
914
  repetition_penalty=repetition_penalty
915
  )
916
+ yield {
 
 
917
  "role": "assistant",
918
  "content": final_answer
919
+ }
 
 
 
 
920
  except Exception as e:
921
+ yield {
 
 
922
  "role": "assistant",
923
+ "content": f"An error occurred: {str(e)}"
924
+ }
925
+
926
+ # Helper function to generate responses from the LLM
927
  def generate_llm_response(
928
+ conversation: List[Dict[str, str]],
929
  max_new_tokens: int,
930
  temperature: float,
931
  top_p: float,
 
933
  repetition_penalty: float
934
  ) -> str:
935
  """Generate a response from the LLM based on the conversation."""
 
 
 
936
  input_ids = tokenizer.apply_chat_template(
937
  conversation,
938
  return_tensors="pt",
 
961
  pad_token_id=tokenizer.eos_token_id,
962
  )
963
 
964
+ t = Thread(
965
+ target=model.generate,
966
+ kwargs=generate_kwargs
967
+ )
968
  t.start()
969
 
970
  # Collect the output
 
974
 
975
  return "".join(outputs)
976
 
 
 
 
 
 
 
 
 
 
977
 
978
+ def append_text_knowledge(file_path: str) -> str:
979
+ """
980
+ Reads content from a selected file and returns it as a string.
981
+
982
+ Args:
983
+ file_path (str): Path to the selected file
984
+
985
+ Returns:
986
+ str: Content of the file or empty string if no file selected
987
+ """
988
+ if file_path:
989
+ try:
990
+ with open(file_path, "r", encoding="utf-8") as f:
991
+ return f.read()
992
+ except Exception as e:
993
+ print("Error reading file: {e}")
994
+ return ""
995
+ return ""
996
+
997
  knowledge_textbox = gr.Textbox(
998
  label="Knowledge Text",
999
+ lines= 20,
1000
  visible=False
1001
  )
1002
 
1003
+ chat_interface = gr.ChatInterface(
1004
+ fn=generate,
1005
+ type="messages",
1006
+ multimodal=True,
1007
+ additional_inputs=[
1008
+ knowledge_textbox,
1009
+ gr.Textbox(label="System prompt", lines=6),
1010
+ gr.Slider(
1011
+ label="Max new tokens",
1012
+ minimum=1,
1013
+ maximum=MAX_MAX_NEW_TOKENS,
1014
+ step=1,
1015
+ value=DEFAULT_MAX_NEW_TOKENS,
1016
+ ),
1017
+ gr.Slider(
1018
+ label="Temperature",
1019
+ minimum=0.1,
1020
+ maximum=4.0,
1021
+ step=0.1,
1022
+ value=0.2,
1023
+ ),
1024
+ gr.Slider(
1025
+ label="Top-p (nucleus sampling)",
1026
+ minimum=0.05,
1027
+ maximum=1.0,
1028
+ step=0.05,
1029
+ value=0.8,
1030
+ ),
1031
+ gr.Slider(
1032
+ label="Top-k",
1033
+ minimum=1,
1034
+ maximum=1000,
1035
+ step=1,
1036
+ value=50,
1037
+ ),
1038
+ gr.Slider(
1039
+ label="Repetition penalty",
1040
+ minimum=1.0,
1041
+ maximum=2.0,
1042
+ step=0.05,
1043
+ value=1.0,
1044
+ ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1045
  ],
1046
+ stop_btn=True,
1047
+ cache_examples=False,
1048
+ show_progress="full",
1049
+ run_examples_on_click=False
1050
  )
1051
+
1052
+ with gr.Blocks() as demo:
1053
+ fe = gr.FileExplorer(
1054
+ glob="**/*.txt",
1055
+ file_count="single",
1056
+ label="Upload an elicitation file",
1057
+ show_label=True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1058
  )
1059
+ fe.change(append_text_knowledge, fe, knowledge_textbox)
1060
+ chat_interface.render()
1061
 
 
1062
  if __name__ == "__main__":
1063
  auth = HuggingFaceLogin()
1064
  if auth.login():
1065
  print("Login successful!")
1066
+ demo.queue().launch()