Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ClaudioMartinH
Copy link
Contributor

No description provided.

@ClaudioMartinH ClaudioMartinH requested a review from a team as a code owner November 24, 2024 21:44
@ClaudioMartinH ClaudioMartinH linked an issue Nov 24, 2024 that may be closed by this pull request
Copy link

@ClaudioMartinH ClaudioMartinH self-assigned this Nov 24, 2024
@ClaudioMartinH
Copy link
Contributor Author

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({
Copy link
Collaborator

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 () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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`
Copy link
Collaborator

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(
Copy link
Collaborator

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',
Copy link
Collaborator

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({
Copy link
Collaborator

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() }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fn unitaria

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[BE][WIKI api/v1/resources/generate-description
2 participants