Skip to content
代码片段 群组 项目
提交 5fd1e4ab 编辑于 作者: Gosia Ksionek's avatar Gosia Ksionek 提交者: Jan Provaznik
浏览文件

Refactor rake task for easier use with yml

上级 89f2edea
No related branches found
No related tags found
无相关合并请求
"Can you explain the code ""def hello_world\\nputs(\""Hello, world!\\n\"");\nend""?",ExplainCode
"Can you explain function ""def hello_world\\nputs(\""Hello, world!\\n\"");\nend""?",ExplainCode
"Write me tests for function ""def hello_world\\nputs(\""Hello, world!\\n\"");\nend""",ExplainCode
"What is the complexity of the code ""def hello_world\\nputs(\""Hello, world!\\n\"");\nend""?",ExplainCode
"How would the ""def hello_world\\nputs(\""Hello, world!\\n\"");\nend"" code look like in Python?",ExplainCode
"How would you refactor the ""def hello_world\\nputs(\""Hello, world!\\n\"");\nend"" code?",ExplainCode
"Can you fix the bug in my ""def hello_world\\nput(\""Hello, world!\\n\"");\nend"" code?",ExplainCode
"Create an example of how to use method ""def hello_world\\nput(\""Hello, world!\\n\"");\nend""",ExplainCode
"Write documentation for the ""def hello_world\\nput(\""Hello, world!\\n\"");\nend"" code",ExplainCode
Create a function to validate an e-mail address,ExplainCode
Create a tic tac toe game in Javascript,ExplainCode
Create a function in Python to call the spotify API to get my playlists,ExplainCode
Please summarize the %<issue_identifier>s issue,"IssueIdentifier, SummarizeComments"
Summarize the %<issue_identifier>s issue with bullet points,"IssueIdentifier, SummarizeComments"
Can you list all the labels on %<issue_identifier>s issue?,"IssueIdentifier, Resource Reader"
How old is the %<issue_identifier>s issue?,"IssueIdentifier, Resource Reader"
For which milestone is the %<issue_identifier>s issue? And how long until then,"IssueIdentifier, Resource Reader"
Summarize the comments into bullet points on %<issue_identifier>s issue,"IssueIdentifier, SummarizeComments"
How do I change my password in GitLab?,GitlabDocumentation
How do I fork a project?,GitlabDocumentation
How do I clone a repository?,GitlabDocumentation
How do I create a project template?,GitlabDocumentation
explain_code:
-
question: 'Can you explain the code ""def hello_world\\nputs(\""Hello, world!\\n\"");\nend""?'
answer: ['ExplainCode']
-
question: 'Can you explain function ""def hello_world\\nputs(\""Hello, world!\\n\"");\nend""?'
answer: ['ExplainCode']
-
question: 'Write me tests for function ""def hello_world\\nputs(\""Hello, world!\\n\"");\nend""'
answer: ['ExplainCode']
-
question: 'What is the complexity of the code ""def hello_world\\nputs(\""Hello, world!\\n\"");\nend""?'
answer: ['ExplainCode']
-
question: 'How would the ""def hello_world\\nputs(\""Hello, world!\\n\"");\nend"" code look like in Python?'
answer: ['ExplainCode']
-
question: 'How would you refactor the ""def hello_world\\nputs(\""Hello, world!\\n\"");\nend"" code?'
answer: ['ExplainCode']
-
question: 'Can you fix the bug in my ""def hello_world\\nput(\""Hello, world!\\n\"");\nend"" code?'
answer: ['ExplainCode']
-
question: 'Create an example of how to use method ""def hello_world\\nput(\""Hello, world!\\n\"");\nend""'
answer: ['ExplainCode']
-
question: 'Write documentation for the ""def hello_world\\nput(\""Hello, world!\\n\"");\nend"" code'
answer: ['ExplainCode']
-
question: 'Create a function to validate an e-mail address'
answer: ['ExplainCode']
-
question: 'Create a tic tac toe game in Javascript'
answer: ['ExplainCode']
-
question: 'Create a function in Python to call the spotify API to get my playlists'
answer: ['ExplainCode']
issue_analysis:
-
question: 'Please summarize the %<issue_identifier>s issue'
answer: ['IssueIdentifier', 'SummarizeComments']
-
question: 'Summarize the %<issue_identifier>s issue with bullet points'
answer: ['IssueIdentifier', 'SummarizeComments']
-
question: 'Can you list all the labels on %<issue_identifier>s issue?'
answer: ['IssueIdentifier', 'Resource Reader']
-
question: 'How old is the %<issue_identifier>s issue?'
answer: ['IssueIdentifier', 'Resource Reader']
-
question: 'For which milestone is the %<issue_identifier>s issue? And how long until then'
answer: ['IssueIdentifier', 'Resource Reader']
-
question: 'Summarize the comments into bullet points on current issue'
answer: ['IssueIdentifier', 'SummarizeComments']
documentation:
-
question: 'How do I change my password in GitLab'
answer: ['GitlabDocumentation']
-
question: 'How do I fork a project?'
answer: ['GitlabDocumentation']
-
question: 'How do I clone a repository?'
answer: ['GitlabDocumentation']
-
question: 'How do I create a project template?'
answer: ['GitlabDocumentation']
# frozen_string_literal: true
FILENAME = "ee/lib/tasks/gitlab/llm/questions.csv"
FILENAME = "ee/lib/tasks/gitlab/llm/questions.yml"
namespace :gitlab do
namespace :llm do
......@@ -12,18 +12,19 @@ namespace :gitlab do
# if run without quotes and argument, it will use predefined issue
desc 'Synchronously run predefined AI questions'
task :questions, [:issue] => [:environment] do |_t, args|
require 'yaml'
args.with_defaults(issue: 'http://127.0.0.1:3001/jashkenas/Underscore/-/issues/41')
zero_shot_prompt_action = "the action to take, should be one from this list"
counter = 0.0
correct_answers_counter = 0
::CSV.read(FILENAME).each do |row|
next if row[0].blank?
YAML.load_file(FILENAME).values.flatten.each do |row|
counter += 1
question = format(row[0], { issue_identifier: args.issue })
question = format(row['question'], { issue_identifier: args.issue })
logger.info("question: #{question}")
logger.info("expected tool(s): #{row[1]}")
logger.info("expected tool(s): #{row['answer']}")
agent = llm_agent({ content: question, sync: true })
response = agent.execute
......@@ -31,7 +32,7 @@ namespace :gitlab do
actions = agent.prompt.scan(/Action: (?<action>.+?)(?=$)/)
actions.reject! { |action| action.first.start_with?(zero_shot_prompt_action) }
correct_answers_counter += accuracy_check(actions, row[1], response.content)
correct_answers_counter += accuracy_check(actions, row['answer'], response.content)
logger.info("tools used: #{actions}")
logger.info("actual response: #{response.content}")
......@@ -75,7 +76,6 @@ namespace :gitlab do
return 0 if final_answer == Gitlab::Llm::Chain::Answer.default_final_message
actions = actions.flatten
tools = tools.split(', ')
final_rating = 0
if actions == tools
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册