File size: 23,638 Bytes
a2b66dc
ef7bc67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6151bfe
 
 
 
 
 
 
 
 
 
 
 
ef7bc67
 
 
 
 
 
 
 
 
 
6151bfe
ef7bc67
 
 
 
 
 
 
 
 
 
 
 
6151bfe
 
 
ef7bc67
 
 
 
6151bfe
 
 
 
ef7bc67
 
 
 
 
 
 
 
 
 
d6c951b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
import gradio as gr
import json
import html

# %%
# Define the function to call the model
def call_model_llama(input_message):
    from gradio_client import Client  # Assuming this is where Client is from
    # Create the client object
    client = Client("featherless-ai/try-this-model")
    # Call the model with the combined input message
    result = client.predict(
        message=input_message,  # Use the combined message
        model="mattshumer/Reflection-Llama-3.1-70B",
        api_name="/chat"
    )
    # Return the result
    return result



# %%
# Define the function to call the model
def call_model_Gpt4(input_message):
  from gradio_client import Client
  client = Client("KingNish/OpenGPT-4o")
  result = client.predict(
      user_prompt={"text":input_message,"files":[]},
      api_name="/chat"
  )
  return result

# %%
# Define the function to call the model
def call_model_Gemini(input_message):
    from gradio_client import Client  # Assuming this is where Client is from
    # Create the client object
    client = Client("NotASI/Google-AI-Playground")
    # Call the model with the input message
    result = client.predict(
        message={"text": input_message, "files": []},
        api_name="/chat"
    )
    # Return the result
    return result



# Define the function to call the model
def call_model_Gemini1(input_message):
    from gradio_client import Client  # Assuming this is where Client is from
    # Create the client object
    client = Client("NotASI/Google-AI-Playground")
    # Call the model with the input message
    result = client.predict(
		message={"text":input_message,"files":[]},
		model_id="gemini-1.5-flash-exp-0827",
		system_message="You are a friendly Chatbot.",
		max_tokens=4096,
		temperature=0.75,
		top_p=0.95,
		api_name="/chat_1"
    )
    # Return the result
    return result

# Print combined result (Optional)
#print(prompt)
def prompt_comb(input_file):
    # %%
    prompt0="""
    ### Prompt:

    **Objective:**

    Your task is to analyze part information extracted from multiple documents and propose a **generalized Part Identification Number (PIN) layout**. You are provided with multiple part information data blocks. The goal is to identify common and unique parameters across all the parts, then intelligently **propose a single, generalized PIN layout** that can be applied to all parts in the dataset, while ensuring it captures the key attributes that define each part.

    **Instructions:**

    1. **Input Data Format:**
    The input consists of data blocks representing various parts. Each data block includes attributes such as:
    - **Basic Series Name**: The part series identifier (e.g., `M85049/43`, `AS85049/52`).
    - **Connectors**: Lists compatible connectors (e.g., `MILDTL5015`, `MILDTL38999`).
    - **Self-locking Option**: Specifies if the part has a self-locking mechanism (e.g., `S`, `N`, or `-`).
    - **Shell Size**: Describes the available shell sizes (e.g., `8, 10, 12`).
    - **Material and Plating**: Lists the materials and their finishes (e.g., `A: Aluminum`, `N: Nickel`).
    - **Angle**: Describes the angle (e.g., `Straight`, `45°`, `90°`).
    - **Other features**: May include additional details, such as knurl style or dimensions, which can sometimes be relevant.

    Here is an example of a data block:

    ```plaintext
    {
    M85049 Backshells
    AS85049/43 Series - 45° cable clamp strain relief
    For connectors:
    MIL-DTL-5015 crimp MIL-DTL-26482 Series 2 AS81703 Series 3 MIL-DTL-83723 Series 1 & 3
    Ordering information
    Self-locking option: Non self locking
    Shell size: 3, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 44, 48, 61
    Material and plating: N: Aluminum, electroless nickel, W: Aluminum, olive drab cadmium
    }
    
    Task:

    Analyze All Data Blocks: Begin by thoroughly analyzing all the provided part data blocks under the extracted data section. Identify both common features (that appear across most parts) and unique features (that distinguish certain parts).
    Identify Key Attributes: From the data, extract the most significant attributes that are necessary for generating a PIN. These may include, but are not limited to:
    Basic Series Name
    Self-locking Option
    Shell Size
    Material and Plating
    Angle
    Connector Type
    Propose a Generalized PIN Layout: Based on the common and unique features identified across the data blocks, propose a general PIN layout that can be applied across all parts in the dataset. The layout should be flexible enough to accommodate different parts, yet standardized enough to be applied consistently.
    Expected Output:

    Generalized PIN Layout: Your output should propose a single, general layout for the Part Identification Number (PIN). The layout should combine key features, capturing relevant details, but should not be overly complex.
    Do Not Provide Individual PINs for each data block. Instead, your task is to propose one general layout that works across all the parts in the dataset.
    Examples: Based on your analysis, your output might look like:

    <Basic Series>/<Shell Size>-<Self-Locking Option>-<Material/Plating>-<Angle>-<Connector>
    However, you should adapt the structure based on your understanding of the data. For example, if angles are only relevant for certain parts, your proposed layout could conditionally include them. Your final layout should represent a balance between flexibility and simplicity.

    Why This Task is Important: The goal is to automate the process of generating a standardized Part Identification Number (PIN) layout across a large set of data blocks. Your solution should generalize the PIN structure so that it can be applied to various parts, enabling an efficient identification system without manual intervention.

    Few-Shot Learning Examples:
    Given the part information-
    Example 1:
    {
    M85049 Backshells
    AS85049/52 Series - Straight cable clamp strain relief
    For connectors:
    MIL-DTL-5015 crimp MIL-DTL-26482 Series 2 AS81703 Series 3 MIL-DTL-83723 Series 1 & 3
    Self-locking option: S: Self-locking
    Shell size: 3, 8, 10, 12, 14, 16
    Material and plating: N: Aluminum, electroless nickel
    }
    PIN Layout Proposed: AS85049/52-10-S-N-Straight-MILDTL5015

    Example 2:
    {
    M85049 Backshells
    AS85049/43 Series - 45° cable clamp strain relief
    For connectors:
    MIL-DTL-5015 crimp MIL-DTL-26482 Series 2 AS81703 Series 3
    Shell size: 3, 10, 16
    Material and plating: W: Aluminum, olive drab cadmium
    }
    PIN Layout Proposed: AS85049/43-10-N-W-45-MILDTL5015

    """

    # %%
    prompt1="""**Objective:**

    Your task is to propose a **generalized solution** for generating Part Identification Numbers (PINs) that can handle **many styles of PINs and different designations**. You will be provided with data blocks extracted from multiple parts. Your goal is to:
    1. **Challenge the generalization** of PIN generation by identifying common patterns across parts and ensuring flexibility in the layout to accommodate various styles of PINs.
    2. **Design a general solution** that can include different styles of PINs and part designations, ensuring the flexibility to adapt to future variations in part information.

    **Instructions:**

    1. **Input Data Format:**
    The input consists of data blocks representing various parts. Each data block includes attributes such as:
    - **Basic Series Name**: The part series identifier (e.g., `M85049/43`, `AS85049/52`).
    - **Connectors**: Lists compatible connectors (e.g., `MILDTL5015`, `MILDTL38999`).
    - **Self-locking Option**: Specifies if the part has a self-locking mechanism (e.g., `S`, `N`, or `-`).
    - **Shell Size**: Describes the available shell sizes (e.g., `8, 10, 12`).
    - **Material and Plating**: Lists the materials and their finishes (e.g., `A: Aluminum`, `N: Nickel`).
    - **Angle**: Describes the angle (e.g., `Straight`, `45°`, `90°`).
    - **Other features**: May include additional details, such as knurl style or dimensions, which can sometimes be relevant.

    Here is an example of a data block:

    ```plaintext
    {
    M85049 Backshells
    AS85049/43 Series - 45° cable clamp strain relief
    For connectors:
    MIL-DTL-5015 crimp MIL-DTL-26482 Series 2 AS81703 Series 3 MIL-DTL-83723 Series 1 & 3
    Ordering information
    Self-locking option: Non self locking
    Shell size: 3, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 44, 48, 61
    Material and plating: N: Aluminum, electroless nickel, W: Aluminum, olive drab cadmium
    }
    Main Task:

    Generalization Across Multiple Styles: The key challenge is to create a flexible PIN generation solution that generalizes well across multiple styles of parts. Your task is to understand the diversity in the dataset and propose a solution that accommodates different PIN structures and styles, while being able to adapt to future variations.
    Analyze All Data Blocks: Begin by thoroughly analyzing all the provided part data blocks. Identify common patterns (e.g., shell size, self-locking options) and unique variations (e.g., specific connector types or angle requirements).
    Challenge the Generalization: Ensure that your solution is capable of handling diverse PIN formats. This includes accommodating different part designations (e.g., connectors, angles) and ensuring that the PIN format can easily adapt to additional parts that may not follow the same format.
    Design a Flexible PIN Layout: Propose a flexible PIN layout that can apply to all parts, while allowing for multiple styles and designations. The layout should be capable of supporting future parts that may include different attributes or designations not present in the current dataset.
    Expected Output:

    Generalized PIN Layout: Your output should propose a generalized PIN layout that is capable of handling multiple styles and variations of PINs. The layout should be flexible, concise, and capable of accommodating both common and unique features across parts.
    Include Multiple Styles: Your layout should not rely on a single format but should challenge the generalization by including ways to handle parts with different styles and designations. For example, some parts may require angle information (e.g., 45°, 90°), while others may need unique connectors or specific shell sizes.
    Note: You are not asked to fill in individual PINs for each part but rather to propose a general solution that can handle the variations across the entire dataset and future parts.

    Examples:

    The layout should allow for different designations, such as connector types or additional material/plating options, to be inserted where applicable. If the part requires a different designation style, the layout should be able to accommodate that without breaking the overall format.

    Why This Task is Important: The goal is to challenge the generalization of PIN generation by designing a system that can handle multiple styles of PINs and accommodate different designations across a large set of data. The system should be able to adapt to future variations in parts and designations without requiring significant changes.

    Few-Shot Learning Examples:

    Example 1:
    Given the part information:

    {
    M85049 Backshells
    AS85049/52 Series - Straight cable clamp strain relief
    For connectors:
    MIL-DTL-5015 crimp MIL-DTL-26482 Series 2 AS81703 Series 3 MIL-DTL-83723 Series 1 & 3
    Self-locking option: S: Self-locking
    Shell size: 3, 8, 10, 12, 14, 16
    Material and plating: N: Aluminum, electroless nickel
    }
    Generalized PIN Layout :
    AS85049/52:10:S:N:Straight:MILDTL5015

    Example 2:

    {
    M85049 Backshells
    AS85049/43 Series - 45° cable clamp strain relief
    For connectors:
    MIL-DTL-5015 crimp MIL-DTL-26482 Series 2 AS81703 Series 3
    Shell size: 3, 10, 16
    Material and plating: W: Aluminum, olive drab cadmium
    }
    Generalized PIN Layout:
    AS85049/43:10:N:W:45:MILDTL5015
    """

    # %%
    prompt2="""
    ### Prompt2:
    ### Objective:
    Design a **generalized solution** for generating Part Identification Numbers (PINs) that accommodates **multiple styles of PINs and part designations**. Using data blocks extracted from various parts, your goal is to:
    1. **Challenge the generalization** of the PIN generation by identifying common patterns across parts, while ensuring the layout can handle a wide range of PIN styles and part designations.
    2. **Develop a flexible solution** that can adapt to future part variations without major changes, allowing for various attributes and styles in the PINs.

    ### Instructions:

    1. **Input Data Format:**
    Each data block represents a part and includes attributes such as:
    - **Series Name**: Identifier for the part series (e.g., `M85049/43`, `AS85049/52`).
    - **Connectors**: Lists the compatible connectors (e.g., `MILDTL5015`, `MILDTL38999`).
    - **Self-locking Option**: Specifies the locking mechanism, such as `S` for self-locking or `N` for non-self-locking.
    - **Shell Size**: Defines available shell sizes (e.g., `8, 10, 12`).
    - **Material and Plating**: Lists the material and its finish (e.g., `N: Nickel`, `W: Olive drab cadmium`).
    - **Angle**: Describes part angle (e.g., `Straight`, `45°`, `90°`).
    - **Other Features**: May include knurl style or other specifications relevant to the part.

    Example of a data block:
    
    ```plaintext
    {
    M85049 Backshells
    AS85049/43 Series - 45° cable clamp strain relief
    For connectors:
    MIL-DTL-5015 crimp MIL-DTL-26482 Series 2 AS81703 Series 3 MIL-DTL-83723 Series 1 & 3
    Ordering information
    Self-locking option: Non self-locking
    Shell size: 3, 8, 10, 12, 14, 16
    Material and plating: N: Aluminum, electroless nickel; W: Aluminum, olive drab cadmium
    }
    
    Main Task:

    Generalization Across Multiple Styles: Analyze the dataset and propose a flexible solution that accommodates different PIN structures and styles, ensuring it adapts to future variations.
    Analyze Data Blocks: Identify common attributes like shell size, self-locking options, and material. Also, note unique variations like connector types and angles.
    Challenge the Generalization: Design a solution that handles various formats, while also allowing flexibility for future part additions.
    Design a Flexible Layout: Propose a flexible PIN layout applicable to all parts, supporting different designations and attributes.

    **Expected Output**:
    Generalized PIN Layout: Your proposed layout should be flexible and capable of handling multiple styles of PINs.
    Display JSON Output: DO NOT generate Python code for creating the JSON output file.Instead,Generate the PINs using a generalized layout for each data block and display the result directly in the following JSON structure format **Do not generate any PINs for data blocks outside the JSON structure**, Ensure the generated PINs are displayed as a valid JSON format as shown in **Few shot Examples** below and entire output remains within the token limit and .

    Few shot Examples:-
        Example 1:
        {
        M85049 Backshells
        AS85049/52 Series - Straight cable clamp strain relief
        For connectors:
        MIL-DTL-5015 crimp MIL-DTL-26482 Series 2 AS81703 Series 3 MIL-DTL-83723 Series 1 & 3
        Self-locking option: S (Self-locking)
        Shell size: 3, 8, 10, 12, 14, 16
        Material and plating: N (Aluminum, electroless nickel)
        }
        Generalized PIN Layout: AS85049/52:10:S:N:Straight:MILDTL5015
        Example 2:
        {
        M85049 Backshells
        AS85049/43 Series - 45° cable clamp strain relief
        For connectors:
        MIL-DTL-5015 crimp MIL-DTL-26482 Series 2 AS81703 Series 3
        Shell size: 3, 10, 16
        Material and plating: W (Aluminum, olive drab cadmium)
        }
        Generalized PIN Layout: AS85049/43:10:N:W:45:MILDTL5015
        
        **Display JSON Output**: 
        The format should follow this example below:
        {
            "M85049": {
                "43": {
                "AS85049/43:3:N:W:45:MILDTL5015",
                "AS85049/43:10:N:W:45:MILDTL5015",
                "AS85049/43:16:N:W:45:MILDTL5015",
                "AS85049/43:3:N:W:45:MILDTL26482"
                },
                "52": {
                "AS85049/52:3:S:N:Straight:MILDTL5015",
                "AS85049/52:8:S:N:Straight:MILDTL5015",
                "AS85049/52:10:S:N:Straight:MILDTL5015",
                "AS85049/52:16:S:N:Straight:MILDTL83723"
                }
                // Continue for other shell sizes and connectors...
            }
        }
        Note : This Json file syntax above is just to know about the structure of the output format required.    
    """

    # %%
    prompt3="""
    ### Objective:
    Design a **generalized solution** for generating Part Identification Numbers (PINs) that accommodates **multiple styles of PINs and part designations**. Using data blocks extracted from various parts, your goal is to:
    1. **Challenge the generalization** of the PIN generation by identifying common patterns across parts, while ensuring the layout can handle a wide range of PIN styles and part designations.
    2. **Develop a flexible solution** that can adapt to future part variations without major changes, allowing for various attributes and styles in the PINs.

    ### Instructions:

    1. **Input Data Format:**
    Each data block represents a part and includes attributes such as:
    - **Series Name**: Identifier for the part series (e.g., `M85049/43`, `AS85049/52`).
    - **Connectors**: Lists the compatible connectors (e.g., `MILDTL5015`, `MILDTL38999`).
    - **Self-locking Option**: Specifies the locking mechanism, such as `S` for self-locking or `N` for non-self-locking.
    - **Shell Size**: Defines available shell sizes (e.g., `8, 10, 12`).
    - **Material and Plating**: Lists the material and its finish (e.g., `N: Nickel`, `W: Olive drab cadmium`).
    - **Angle**: Describes part angle (e.g., `Straight`, `45°`, `90°`).
    - **Other Features**: May include knurl style or other specifications relevant to the part.

    Example of a data block:
    
    ```plaintext
    {
    M85049 Backshells
    AS85049/43 Series - 45° cable clamp strain relief
    For connectors:
    MIL-DTL-5015 crimp MIL-DTL-26482 Series 2 AS81703 Series 3 MIL-DTL-83723 Series 1 & 3
    Ordering information
    Self-locking option: Non self-locking
    Shell size: 3, 8, 10, 12, 14, 16
    Material and plating: N: Aluminum, electroless nickel; W: Aluminum, olive drab cadmium
    }
    
    Main Task:

    Generalization Across Multiple Styles: Analyze the dataset and propose a flexible solution that accommodates different PIN structures and styles, ensuring it adapts to future variations.
    Analyze Data Blocks: Identify common attributes like shell size, self-locking options, and material. Also, note unique variations like connector types and angles.
    Challenge the Generalization: Design a solution that handles various formats, while also allowing flexibility for future part additions.
    Design a Flexible Layout: Propose a flexible PIN layout applicable to all parts, supporting different designations and attributes.
    Support for Multiple Styles: Your solution should accommodate variations, such as connector types, angles, and material options. The layout should allow for different formats without breaking the system.

    **Expected Output**:
    Generalized PIN Layout: Your proposed layout should be flexible and capable of handling multiple styles of PINs.

    Few shot Examples:-
        Example 1:
        {
        M85049 Backshells
        AS85049/52 Series - Straight cable clamp strain relief
        For connectors:
        MIL-DTL-5015 crimp MIL-DTL-26482 Series 2 AS81703 Series 3 MIL-DTL-83723 Series 1 & 3
        Self-locking option: S (Self-locking)
        Shell size: 3, 8, 10, 12, 14, 16
        Material and plating: N (Aluminum, electroless nickel)
        }
        Generalized PIN Layout: AS85049/52:10:S:N:Straight:MILDTL5015
        Example 2:
        {
        M85049 Backshells
        AS85049/43 Series - 45° cable clamp strain relief
        For connectors:
        MIL-DTL-5015 crimp MIL-DTL-26482 Series 2 AS81703 Series 3
        Shell size: 3, 10, 16
        Material and plating: W (Aluminum, olive drab cadmium)
        }
        Generalized PIN Layout: AS85049/43:10:N:W:45:MILDTL5015    
    """

    # %%
    prompt_list=[]
    prompt_list.append(prompt0)
    prompt_list.append(prompt1)
    prompt_list.append(prompt2)
    prompt_list.append(prompt3)
#print(prompt_list[0])

# %%
    # Function to read text from a file
    def read_text_file(file_name):
        with open(file_name, 'r') as file:
            return file.read()

    # Function to combine input text with file text and add a heading
    def combine_text(input_text, file_name, heading):
        # Read content from the file
        file_text = read_text_file(file_name)
        # Create the combined content with the heading
        combined_text = f"{input_text}\n{heading}\n{file_text}"
        return combined_text

    # Example usage
    heading = "Data Blocks Extracted:"
    prompt_combine=[]

    for prompt in prompt_list:
        # Combine the file with the input text
        prompt_combine.append(combine_text(prompt,input_file,heading))
    return prompt_combine    


# Define the function to call the model
def call_model(model_name, input_file, prompt_name):
    prompt_combine = prompt_comb(input_file)

    if prompt_name == "Basic_v1":
        index = 0
    elif prompt_name == "Basic_v2":
        index = 1  
    elif prompt_name == "Generalize_v1":
        index = 2 
    elif prompt_name == "Generalize_v2":
        index = 3          
    
    input_message = prompt_combine[index]
    
    # Call the selected model
    if model_name == "llama":
        output = call_model_llama(input_message)
    elif model_name == "gpt4":
        output = call_model_Gpt4(input_message)
    elif model_name == "gemini":
        output = call_model_Gemini(input_message)
    else:
        output = call_model_Gemini1(input_message)
    
    # Decode the output
    decoded_string = html.unescape(output)
    return decoded_string

# Define the Gradio interface
def launch_interface():
    # Define the input components
    model_dropdown = gr.Dropdown(["llama", "gpt4", "gemini", "gemini1"], label="Select Model")
    input_file = gr.File(label="Upload JSON File")
    prompt_dropdown = gr.Dropdown(["Basic_v1", "Basic_v2", "Generalize_v1", "Generalize_v2"], label="Select Prompt")

    # Define the output component
    output_text = gr.Textbox(label="Output", interactive=False)

    # Create the Gradio interface with dark theme
    interface = gr.Interface(
        fn=call_model,
        inputs=[model_dropdown, input_file, prompt_dropdown],
        outputs=output_text,
        title="Part Identification Number (PINs)",
        description="Choose a model **(llama-preferred)** and Upload a JSON file, select a prompt **(Generalize_v2-preferred)**, to generalize the PINs.",
        theme="dark",  # Set the theme to dark
    
    )

    return interface

# Launch the Gradio app
if __name__ == "__main__":  
    import sys
    sys.stdout.reconfigure(encoding='utf-8')

    interface = launch_interface()  
    interface.launch()  # Create a public link