-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controler and testing for new endpoint generate-description #1571
base: main
Are you sure you want to change the base?
Controler and testing for new endpoint generate-description #1571
Conversation
Quality Gate passed for 'ita-wiki-back'Issues Measures |
Security Note: During the development of this feature, a personal Hugging Face API key was temporarily included to allow tests to run correctly on GitHub Actions. After the tests were completed, the key was revoked to mitigate any security risks. This key is personal and not associated with the project. |
@@ -0,0 +1,13 @@ | |||
import { knexResourceSchema } from './resourceSchema' | |||
|
|||
export const generateDescriptionSchema = knexResourceSchema.omit({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pick
expect(response.status).toBe(200) | ||
expect(response.body).toHaveProperty('description') | ||
}) | ||
it('should fail is language param is missing', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('should fail is language param is missing', async () => { | |
it('should fail if language param is missing', async () => { |
import { authToken } from '../mocks/ssoHandlers/authToken' | ||
import { checkInvalidToken } from '../helpers/checkInvalidToken' | ||
|
||
const url: string = `${pathRoot.v1.resources}/generate-description` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
objeto
} | ||
const input = getLanguageInput(language as string, title, url, topic) | ||
|
||
const response = await fetch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to repository pattern
const input = getLanguageInput(language as string, title, url, topic) | ||
|
||
const response = await fetch( | ||
'https://api-inference.huggingface.co/models/Qwen/Qwen2.5-Coder-32B-Instruct', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env variable
Authorization: `Bearer ${process.env.HUGGINGFACE_API_KEY}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env variable
|
||
const description = await response.json() | ||
ctx.status = 200 | ||
ctx.body = { description: description[0]?.generated_text.trim() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn unitaria
No description provided.