diff --git a/src/app/campaigns/components/draft-campaign-presentation/draft-campaign-presentation.component.ts b/src/app/campaigns/components/draft-campaign-presentation/draft-campaign-presentation.component.ts index a79e7b3e6..92962dd4d 100755 --- a/src/app/campaigns/components/draft-campaign-presentation/draft-campaign-presentation.component.ts +++ b/src/app/campaigns/components/draft-campaign-presentation/draft-campaign-presentation.component.ts @@ -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; + }) } diff --git a/src/app/core/services/campaign/campaign.service.ts b/src/app/core/services/campaign/campaign.service.ts index a78ae3a66..e2a31fabd 100755 --- a/src/app/core/services/campaign/campaign.service.ts +++ b/src/app/core/services/campaign/campaign.service.ts @@ -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) { diff --git a/src/app/http-interceptor.service.ts b/src/app/http-interceptor.service.ts index 09619bf43..30122cbcd 100644 --- a/src/app/http-interceptor.service.ts +++ b/src/app/http-interceptor.service.ts @@ -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`, diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 15accfabf..1c0e09a83 100755 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -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: { diff --git a/src/environments/environment.ts b/src/environments/environment.ts index f958bb7e7..5cdb63b27 100755 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -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: