Copilot Response Formatting #125557
Replies: 2 comments 3 replies
-
|
Did you try to debug it, to see that you are capturing a request and that it is being executed? Did you configure the proxy for your IDE maybe? You should also be capturing only the relevant request for which you want to format the response. You can also try the following sample, to manually format the captured github copilot response: from mitmproxy import http
import json
import subprocess
def lint_code(code: str) -> str:
result = subprocess.run(['pylint', '--from-stdin', 'dummy.py'], input=code.encode(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
linted_code = result.stdout.decode('utf-8') if result.stdout else code
return linted_code
def response(flow: http.HTTPFlow) -> None:
if "copilot.github.com" in flow.request.host:
try:
response_data = json.loads(flow.response.content)
original_code = response_data.get('choices', [{}])[0].get('text', '')
linted_code = lint_code(original_code)
response_data['choices'][0]['text'] = linted_code
flow.response.content = json.dumps(response_data)
except Exception as e:
print(f"Error processing response: {e}") |
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Question
Body
Hi there,
I am using GitHub Copilot since few months. I want to modify the copilot response. I am doing this by following way:
But in copilot chat nothing gets printed. Can anyone help me here.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions