Refactor Dockerfile and add linguist module
This commit refactors the Dockerfile to: - Reintroduce the programmer user creation with sudo privileges - Add necessary system dependencies for development tools - Update Go installation to include PATH in root's bashrc - Install github-linguist gem It also includes the addition of a new linguist command module with functions to interact with GitHub Linguist for language statistics and file information retrieval.
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
import json
|
||||
import re
|
||||
|
||||
from ollama import prompt
|
||||
|
||||
|
||||
def structure_to_json(text, schema):
|
||||
"""
|
||||
Convert structured text to JSON using Ollama.
|
||||
|
||||
Args:
|
||||
text (str): The structured text to convert
|
||||
schema (dict): The JSON schema to use for conversion
|
||||
|
||||
Returns:
|
||||
dict: The parsed JSON object
|
||||
"""
|
||||
# Format the schema as JSON string
|
||||
schema_json = json.dumps(schema, indent=2)
|
||||
|
||||
# Create the prompt following the pattern from your bash command
|
||||
full_prompt = f"""Transform the following structured text into JSON according to the given schema.
|
||||
|
||||
**Return only valid JSON, without any Markdown formatting :**
|
||||
- no backticks,
|
||||
- no code blocks,
|
||||
- no extra text
|
||||
|
||||
Input text:
|
||||
{text}
|
||||
|
||||
Schema:
|
||||
{schema_json}"""
|
||||
|
||||
# Send to Ollama
|
||||
response = prompt("qwen3:0.6b", full_prompt, allow_pull=True)
|
||||
|
||||
# Remove any markdown formatting (backticks, code blocks) that Ollama might include
|
||||
# Only remove backticks at the beginning or end of the response, not those within the JSON
|
||||
clean_response = response.strip()
|
||||
while clean_response.startswith("`") or clean_response.startswith("```"):
|
||||
clean_response = clean_response[1:].strip()
|
||||
while clean_response.endswith("`") or clean_response.endswith("```"):
|
||||
clean_response = clean_response[:-1].strip()
|
||||
|
||||
# Try to parse the response as JSON
|
||||
try:
|
||||
return json.loads(clean_response)
|
||||
except json.JSONDecodeError:
|
||||
# If parsing fails, return the raw response
|
||||
return {"error": "Failed to parse JSON", "raw_response": clean_response}
|
||||
Reference in New Issue
Block a user