update prompt
This commit is contained in:
@@ -1,22 +1,11 @@
|
|||||||
{
|
{
|
||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "markdown",
|
||||||
"execution_count": 1,
|
"id": "ff022957-2e81-4ea9-84d3-e52d5753e133",
|
||||||
"id": "6d67dba5-38ec-459a-9132-4a56c6a814cd",
|
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"ename": "SyntaxError",
|
|
||||||
"evalue": "invalid syntax (2447672335.py, line 1)",
|
|
||||||
"output_type": "error",
|
|
||||||
"traceback": [
|
|
||||||
"\u001b[1;36m Cell \u001b[1;32mIn[1], line 1\u001b[1;36m\u001b[0m\n\u001b[1;33m Comment and Unit Test Generater\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"Comment and Unit Test Generater \n",
|
"### Comment and Unit Test Generater \n",
|
||||||
"\n",
|
"\n",
|
||||||
"The requirement: \n",
|
"The requirement: \n",
|
||||||
"* use an LLM to generate docstring and comments for Python code\n",
|
"* use an LLM to generate docstring and comments for Python code\n",
|
||||||
@@ -164,7 +153,6 @@
|
|||||||
" - All parameters with types and descriptions\n",
|
" - All parameters with types and descriptions\n",
|
||||||
" - Return values with types\n",
|
" - Return values with types\n",
|
||||||
" - Exceptions that may be raised\n",
|
" - Exceptions that may be raised\n",
|
||||||
" - At least one usage example\n",
|
|
||||||
" - Any important notes or limitations\n",
|
" - Any important notes or limitations\n",
|
||||||
" \n",
|
" \n",
|
||||||
" 2. Strategic inline comments for:\n",
|
" 2. Strategic inline comments for:\n",
|
||||||
@@ -415,7 +403,7 @@
|
|||||||
" messages = messages_for_comment(code)\n",
|
" messages = messages_for_comment(code)\n",
|
||||||
" text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)\n",
|
" text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)\n",
|
||||||
" client = InferenceClient(model_url, token=hf_token)\n",
|
" client = InferenceClient(model_url, token=hf_token)\n",
|
||||||
" stream = client.text_generation(text, stream=True, details=True, max_new_tokens=3000)\n",
|
" stream = client.text_generation(text, stream=True, details=True, max_new_tokens=5000)\n",
|
||||||
" result = \"\"\n",
|
" result = \"\"\n",
|
||||||
" for r in stream:\n",
|
" for r in stream:\n",
|
||||||
" #print(r.token.text, end = \"\")\n",
|
" #print(r.token.text, end = \"\")\n",
|
||||||
@@ -522,7 +510,9 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "ee27cc91-81e6-42c8-ae3c-c04161229d8c",
|
"id": "ee27cc91-81e6-42c8-ae3c-c04161229d8c",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"scrolled": true
|
||||||
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"with gr.Blocks(css=css) as ui:\n",
|
"with gr.Blocks(css=css) as ui:\n",
|
||||||
@@ -539,7 +529,7 @@
|
|||||||
" \n",
|
" \n",
|
||||||
" comment_button.click(comment_code, inputs=[python, model], outputs=[result])\n",
|
" comment_button.click(comment_code, inputs=[python, model], outputs=[result])\n",
|
||||||
" unit_test_button.click(get_unit_test, inputs=[python, model], outputs=[result])\n",
|
" unit_test_button.click(get_unit_test, inputs=[python, model], outputs=[result])\n",
|
||||||
"ui.launch(inbrowser=False)"
|
"ui.launch(inbrowser=True)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user