| 39 | |
| 40 | # Define a function to generate code based on the input |
| 41 | def generate_code(input): |
| 42 | # Get relevant nodes from the Figma document retriever |
| 43 | relevant_nodes = figma_doc_retreiver.get_relevant_documents(input) |
| 44 | |
| 45 | # Create system and human message prompts |
| 46 | system_message_prompt = SystemMessagePromptTemplate.from_template(system_prompt_template) |
| 47 | human_message_prompt = HumanMessagePromptTemplate.from_template(human_prompt_template) |
| 48 | |
| 49 | # Create the chat prompt using the system and human message prompts |
| 50 | conversation = [system_message_prompt, human_message_prompt] |
| 51 | chat_prompt = ChatPromptTemplate.from_messages(conversation) |
| 52 | response = gpt_4(chat_prompt.format_prompt( |
| 53 | context=relevant_nodes, |
| 54 | text=input).to_messages()) |
| 55 | |
| 56 | return response.content |
| 57 | |
| 58 | # Add argument parsing to allow for command-line input |
| 59 | parser = argparse.ArgumentParser(description='Generate HTML/CSS code based on input.') |