This is a LLM app using Python/FastAPI, langchain and langgraph.
- Use data in memory for cache, storage, and queue.
- Max 50 lines per function
- Use descriptive variable names
- Use the latest stable versions of all libraries.
| import org.springframework.ai.chat.prompt.Prompt; | |
| import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatModel; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.web.bind.annotation.*; | |
| @RestController | |
| @RequestMapping("/api/gemini") | |
| public class GeminiController { | |
| @Autowired |
| import org.springframework.ai.chat.prompt.Prompt; | |
| import org.springframework.ai.openai.OpenAiChatModel; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.web.bind.annotation.GetMapping; | |
| import org.springframework.web.bind.annotation.RequestMapping; | |
| import org.springframework.web.bind.annotation.RequestParam; | |
| import org.springframework.web.bind.annotation.RestController; | |
| @RestController | |
| @RequestMapping("/api/openai") |
| dependencies { | |
| implementation 'org.springframework.boot:spring-boot-starter-web' | |
| implementation 'org.springframework.ai:spring-ai-openai-spring-boot-starter' | |
| implementation 'org.springframework.ai:spring-ai-vertex-ai-gemini-spring-boot-starter' | |
| testImplementation 'org.springframework.boot:spring-boot-starter-test' | |
| testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | |
| } |
| import org.springframework.boot.SpringApplication; | |
| import org.springframework.boot.autoconfigure.SpringBootApplication; | |
| @SpringBootApplication | |
| public class ChatAppSpringApplication { | |
| public static void main(String[] args) { | |
| SpringApplication.run(ChatAppSpringApplication.class, args); | |
| } | |
| } |
| @Component({ | |
| selector: 'app-password-field', | |
| templateUrl: './password-field.component.html', | |
| standalone: true, | |
| changeDetection: ChangeDetectionStrategy.OnPush, | |
| imports: [ReactiveFormsModule, StrengthMeterComponent] | |
| }) | |
| export class PasswordFieldComponent implements OnInit { | |
| destroyRef = inject(DestroyRef); | |
| @Input() passwordFormControl: FormControl = new FormControl<any>(''); |
| nameAlreadyExists: boolean = false; | |
| private notifyParentComponentWhenNameChanges(): void { | |
| this.form | |
| ?.get('name') | |
| ?.valueChanges.pipe( | |
| takeUntilDestroyed(this.destroyRef), | |
| debounceTime(300), // debounce user input | |
| distinctUntilChanged() | |
| ) |
| @Component({ | |
| selector: 'app-ecs-field', | |
| templateUrl: './ecs-field.component.html', | |
| changeDetection: ChangeDetectionStrategy.OnPush, | |
| }) | |
| export class EcsFieldComponent implements OnInit, OnChanges { | |
| private storeService = inject(EcsFieldsStoreService); | |
| nameAlreadyExists: boolean = false; | |
| @Component({ | |
| selector: 'app-ecs-field', | |
| templateUrl: './ecs-field.component.html', | |
| changeDetection: ChangeDetectionStrategy.OnPush, | |
| }) | |
| export class EcsFieldComponent { | |
| formBuilder = inject(FormBuilder); | |
| @Input() entity: EcsField; | |
| @Input() nameAlreadyExists: boolean | null = false; |
| @Component({ | |
| selector: 'app-ecs-fieldset', | |
| templateUrl: './ecs-fieldset.component.html', | |
| changeDetection: ChangeDetectionStrategy.OnPush, | |
| }) | |
| export class EcsFieldsetComponent { | |
| formBuilder = inject(FormBuilder); | |
| @Input() entity: EcsFieldset; | |
| @Input() nameAlreadyExists: boolean | null = false; |