Use completions endpoint
This commit is contained in:
		
							parent
							
								
									42bf3f0e98
								
							
						
					
					
						commit
						f1b7787553
					
				
							
								
								
									
										13
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								app.py
									
									
									
									
									
								
							| @ -5,7 +5,8 @@ from moviepy import VideoFileClip | ||||
| from openai import OpenAI | ||||
| from pydub import AudioSegment | ||||
| 
 | ||||
| DEFAULT_PROMPT = "The user will provided a video transcription for which you are to generate a blog post in Markdown format summarizing the video contents.  Please only output the blog post content." | ||||
| from prompt import DEFAULT_PROMPT | ||||
| 
 | ||||
| VIDEO_URL = os.getenv('INPUT_VIDEO_URL', None) | ||||
| OUTPUT_PATH = os.getenv('OUTPUT_PATH', 'tmp') | ||||
| AUDIO_SEGMENT_DURATION = 30000 | ||||
| @ -59,13 +60,9 @@ def transcribe_audio(openai_client, audio_segments): | ||||
|         ]) | ||||
| 
 | ||||
| def summarize_transcription(openai_client, transcription): | ||||
|     return openai_client.chat.completions.create( | ||||
|     return openai_client.completions.create( | ||||
|             model=OPENAI_CHAT_MODEL,  | ||||
|             n=OPENAI_CHAT_N, | ||||
|             messages = [ | ||||
|                 {"role": "developer", "content": OPENAI_CHAT_SYSTEM_PROMPT}, | ||||
|                 {"role": "user", "content": transcription} | ||||
|                 ] | ||||
|             prompt=OPENAI_CHAT_SYSTEM_PROMPT.format(transcription) | ||||
|             ).choices | ||||
| 
 | ||||
| def setup(): | ||||
| @ -79,4 +76,4 @@ if __name__ == '__main__': | ||||
|     setup() | ||||
|     for each in main(): | ||||
|         print("========") | ||||
|         print(each.message.content) | ||||
|         print(each.text) | ||||
|  | ||||
							
								
								
									
										19
									
								
								prompt.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								prompt.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| DEFAULT_PROMPT = """ | ||||
| You are a professional blog writer and SEO expert.  You will be given the transcript of a live stream for which you are to generate | ||||
| a blog post. | ||||
|              | ||||
| Instructions: | ||||
|     - The blog post title should be SEO optimized. | ||||
|     - The blog post should be properly and beautifully formatted using markdown. | ||||
|     - Each blog post should have around 5 sections with 3 sub-sections each. | ||||
|     - Each sub section should have about 3 paragraphs. | ||||
|     - Sub-section headings should be clearly marked. | ||||
|     - Ensure that the content flows logically from one section to another, maintaining coherence and readability. | ||||
|     - In the final section, provide a forward-looking perspective on the topic and a conclusion. | ||||
|     - Make the blog post sound as human and as engaging as possible, add real world examples and make it as informative as possible. | ||||
|     - Please ensure proper and standard markdown formatting always. | ||||
| 
 | ||||
| Transcription: {} | ||||
| 
 | ||||
| Blog Post:  | ||||
| """ | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user