JSenkCC commited on
Commit
157af84
·
verified ·
1 Parent(s): c204d8b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -391,8 +391,8 @@ def validate_and_generate_documentation(api_url, headers, gemini_output, functio
391
  """
392
  Uses the Hugging Face Inference API to generate clean and relevant documentation using Qwen.
393
  """
394
- # Clean Gemini output
395
  cleaned_gemini_output = extract_cleaned_gemini_output(gemini_output)
 
396
 
397
  # Generate the refined prompt for Qwen
398
  prompt = f"""
@@ -433,7 +433,6 @@ def validate_and_generate_documentation(api_url, headers, gemini_output, functio
433
  5. Return only the required information for the above tasks, and exclude everything else.
434
  """
435
 
436
- # Prepare payload and call API
437
  payload = {"inputs": prompt, "parameters": {"max_new_tokens": 1024}}
438
  response = requests.post(api_url, headers=headers, json=payload)
439
 
@@ -441,7 +440,11 @@ def validate_and_generate_documentation(api_url, headers, gemini_output, functio
441
  if response.status_code == 200:
442
  api_response = response.json()
443
  output = api_response.get("generated_text", "") if isinstance(api_response, dict) else api_response[0].get("generated_text", "")
444
- return clean_output(output)
 
 
 
 
445
  else:
446
  raise ValueError(f"Error during API call: {response.status_code}, {response.text}")
447
 
 
391
  """
392
  Uses the Hugging Face Inference API to generate clean and relevant documentation using Qwen.
393
  """
 
394
  cleaned_gemini_output = extract_cleaned_gemini_output(gemini_output)
395
+ gemini_output_length = len(cleaned_gemini_output) # Record the length of the cleaned Gemini output
396
 
397
  # Generate the refined prompt for Qwen
398
  prompt = f"""
 
433
  5. Return only the required information for the above tasks, and exclude everything else.
434
  """
435
 
 
436
  payload = {"inputs": prompt, "parameters": {"max_new_tokens": 1024}}
437
  response = requests.post(api_url, headers=headers, json=payload)
438
 
 
440
  if response.status_code == 200:
441
  api_response = response.json()
442
  output = api_response.get("generated_text", "") if isinstance(api_response, dict) else api_response[0].get("generated_text", "")
443
+
444
+ # Remove the Gemini content from the top of the Qwen output
445
+ trimmed_output = output[gemini_output_length:].strip()
446
+
447
+ return clean_output(trimmed_output) # Final cleanup if necessary
448
  else:
449
  raise ValueError(f"Error during API call: {response.status_code}, {response.text}")
450