clean text
This commit is contained in:
parent
01d4fab793
commit
3096e2dc77
94
extension.js
94
extension.js
|
@ -36,6 +36,81 @@ class ApiResponseViewProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const prompt_docscting = `
|
||||||
|
You are a specialized Python documentation assistant. When given Python code, generate a comprehensive docstring following this specific format:
|
||||||
|
|
||||||
|
1. First line: Brief, clear description of what the function/class does
|
||||||
|
2. Empty line after description
|
||||||
|
3. Args section (if there are parameters):
|
||||||
|
- Each parameter on a new line
|
||||||
|
- Format: parameter_name (type): description
|
||||||
|
- Include type hints in parentheses
|
||||||
|
- Detailed description of parameter purpose and constraints
|
||||||
|
4. Returns section (if the function returns something):
|
||||||
|
- Detailed description of return value(s)
|
||||||
|
- For complex return types, include full type annotation
|
||||||
|
- For multiple return values, list each component
|
||||||
|
5. Raises section (if applicable):
|
||||||
|
- List exceptions that may be raised
|
||||||
|
- Include when and why they occur
|
||||||
|
|
||||||
|
Rules for writing:
|
||||||
|
- Always use triple double quotes (""")
|
||||||
|
- Keep first line concise but informative
|
||||||
|
- Be specific about types, including nested types (List[Dict], Tuple[str, int], etc.)
|
||||||
|
- For complex return types, break them down with bullet points
|
||||||
|
- Indentation should match the function's indentation level
|
||||||
|
- Use consistent capitalization (start each section with capital letter)
|
||||||
|
- Don't include implementation details, focus on interface
|
||||||
|
- Be explicit about optional parameters and default values
|
||||||
|
- For collections, specify the structure of contained elements
|
||||||
|
|
||||||
|
Example Format:
|
||||||
|
|
||||||
|
"""
|
||||||
|
Brief description of function purpose.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
param1 (type): Description of first parameter.
|
||||||
|
param2 (type): Description of second parameter.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
type: Description of return value.
|
||||||
|
- bullet points for complex returns
|
||||||
|
- explaining each component
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ExceptionType: Description of when/why exception occurs.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
Focus on:
|
||||||
|
- Accuracy of type annotations
|
||||||
|
- Clarity of descriptions
|
||||||
|
- Completeness of information
|
||||||
|
- Consistency in formatting
|
||||||
|
- Technical precision
|
||||||
|
|
||||||
|
You will receive Python code and should respond with only the appropriate docstring, maintaining exact indentation and following all format rules above.
|
||||||
|
`;
|
||||||
|
|
||||||
|
function formatApiResponse(apiResponse) {
|
||||||
|
// Extraer el contenido de la respuesta
|
||||||
|
const rawContent = apiResponse.content;
|
||||||
|
|
||||||
|
// El contenido viene con comillas y barras invertidas adicionales
|
||||||
|
// Primero eliminamos las comillas al inicio y final
|
||||||
|
let cleanContent = rawContent.replace('\\', '###');
|
||||||
|
|
||||||
|
// Luego reemplazamos los caracteres de escape de las comillas triples
|
||||||
|
//cleanContent = cleanContent.replace(/\\"\\"\\"/g, '########');
|
||||||
|
|
||||||
|
// Eliminamos cualquier barra invertida adicional que esté escapando caracteres
|
||||||
|
//cleanContent = cleanContent.replace(/\\\\/g, '\\');
|
||||||
|
//cleanContent = cleanContent.replace(/\\n/g, '\n');
|
||||||
|
|
||||||
|
return cleanContent;
|
||||||
|
}
|
||||||
|
|
||||||
function activate(context) {
|
function activate(context) {
|
||||||
const apiResponseProvider = new ApiResponseViewProvider();
|
const apiResponseProvider = new ApiResponseViewProvider();
|
||||||
|
@ -67,18 +142,19 @@ function activate(context) {
|
||||||
title: "Enviando código a la API...",
|
title: "Enviando código a la API...",
|
||||||
cancellable: false
|
cancellable: false
|
||||||
}, async (progress) => {
|
}, async (progress) => {
|
||||||
const response = await fetch('http://127.0.0.1:7869/api/v2/text/text', {
|
const response = await fetch('https://allapi.desarrollo.ciditel.net/api/v2/text/text', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify(
|
body: JSON.stringify(
|
||||||
{"server":"groq",
|
|
||||||
"model":"deepseek-r1-distill-llama-70B",
|
{"server":"groq",
|
||||||
"system":"Te dare un codigo de python quiero que generes el docstring tomando el cuenta el codigo",
|
"model":"llama3.3-70b-it",
|
||||||
"content":selectedText,
|
"system":prompt_docscting,
|
||||||
"password": "1223Aer*",
|
"content":selectedText,
|
||||||
"userid": "Anon"}
|
"password": "1223Aer*",
|
||||||
|
"userid": "Anon"}
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -87,7 +163,9 @@ function activate(context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
apiResponseProvider.updateResponse(JSON.stringify(data, null, 2));
|
|
||||||
|
const data2 = formatApiResponse(data);
|
||||||
|
apiResponseProvider.updateResponse(JSON.stringify(data2, null, 2));
|
||||||
|
|
||||||
// Notificar que la respuesta está lista para usar
|
// Notificar que la respuesta está lista para usar
|
||||||
vscode.window.showInformationMessage('Respuesta de API guardada - usa el botón derecho para pegarla');
|
vscode.window.showInformationMessage('Respuesta de API guardada - usa el botón derecho para pegarla');
|
||||||
|
|
Loading…
Reference in New Issue