Skip to content

Commit

Permalink
move generate brief api to our backend (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
hichri-louay authored Oct 4, 2023
1 parent 8d0fb87 commit 059f184
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,17 @@ export class DraftCampaignPresentationComponent implements OnInit {

generateBrief() {
this.isGenerating = true;
this.campaignFacade.generateBriefIA(this.form.get('title')?.value).subscribe((data:any) => {
this.ai_result= data.choices[0].message.content;
this.form.patchValue({ description: this.ai_result });
this.isGenerating = false;
})
this.campaignFacade.generateBriefIA(this.form.get('title')?.value).subscribe(
(data:any) => {
if(data.message === 'success') {
this.ai_result= data.data.choices[0].message.content;
this.form.patchValue({ description: this.ai_result });
this.isGenerating = false;
} else this.isGenerating = false;

}, (err:any) => {
this.isGenerating = false;
})
}


Expand Down
16 changes: 4 additions & 12 deletions src/app/core/services/campaign/campaign.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,11 @@ export class CampaignHttpApiService {
});
}
generateBrief(title: string) {
console.log(title);
const apiUrl = 'https://api.openai.com/v1/chat/completions';
const payload = {
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "please create a comprehensive Influencer Campaign Brief for me that will serve as an explanatory sheet for integration into a campaign presentation platform. We need title, description, short description, rules, and examples."+ title, }],
"temperature": 0.7
};

const headers = new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer ' + env.API_AI,


return this.http.post(sattUrl + '/campaign/generate-brief', {
title
});
return this.http.post(`${apiUrl}`, payload, { headers });
}

getBestInfluencerPic(id: any) {
Expand Down
1 change: 1 addition & 0 deletions src/app/http-interceptor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class HttpInterceptorService implements HttpInterceptor {
`${environment.API_URL}/campaign/statLinkCampaign`,
`${environment.API_URL}/campaign/reject`,
`${environment.API_URL}/campaign/deleteDraft`,
`${environment.API_URL}/campaign/generate-brief`,

// PROFILE API
`${environment.API_URL}/profile/picture`,
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const environment = {
'https://api.thegraph.com/subgraphs/name/atayen/satt--bsc-mainnet',
url_subgraph_ether:
'https://api.thegraph.com/subgraphs/name/atayen/satt-ether-mainnet',
API_AI: '',


addresses: {
smartContracts: {
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const environment = {
//https://api-preprod2.satt-token.com

API_URL: 'https://api-preprod2.satt-token.com',
API_AI: '',

url_subgraph_bsc:
'https://api.thegraph.com/subgraphs/name/atayen/satt-testnet',
url_subgraph_ether:
Expand Down

0 comments on commit 059f184

Please sign in to comment.